Using a standalone cache for frequently accessed items
In this recipe, we will see how to use a standalone cache for frequently accessed items. A cache is a temporary data store that will save the items in memory and will provide those from the memory itself instead of making a DynamoDB call. Make a note that this should be used for items, which you expect to not be changed frequently.
Getting ready
We will perform this recipe using Java libraries. So, the prerequisite is that you should have performed recipes, which use the AWS SDK for Java.
How to do it…
Here, we will be using the AWS SDK for Java, so create a Maven project with the SDK dependency. Apart from the SDK, we will also be using one of the most widely used open source caches, that is, EhCache
. To know about EhCache
, refer to http://ehcache.org/.
Let's use a standalone cache for frequently accessed items:
To use
EhCache
, we need to include the following repository inpom.xml
:<repositories> <repository> <id>sourceforge...