public class SimpleInMemoryCacheManager extends java.lang.Object implements CacheManager
This implementation mainly serves as an example. Do not use this cache manager when your application is deployed as multiple replicas! In that case a centralized cache (e.g. Redis) is advisable.
| Modifier and Type | Class and Description |
|---|---|
static class |
SimpleInMemoryCacheManager.CacheTag |
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode> |
cache |
protected java.util.concurrent.atomic.AtomicInteger |
hits |
protected java.util.concurrent.atomic.AtomicInteger |
puts |
protected java.util.concurrent.atomic.AtomicInteger |
queries |
protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
tagsForUrls |
| Constructor and Description |
|---|
SimpleInMemoryCacheManager() |
| Modifier and Type | Method and Description |
|---|---|
com.fasterxml.jackson.databind.JsonNode |
get(java.lang.String url)
Retrieve an earlier cached response from the Kontent.ai Delivery API.
|
void |
invalidate(SimpleInMemoryCacheManager.CacheTag cacheTag) |
void |
invalidate(java.lang.String url) |
void |
put(java.lang.String url,
com.fasterxml.jackson.databind.JsonNode jsonNode,
java.util.List<ContentItem> containedContentItems)
Cache a response from the Kontent.ai Delivery API.
|
protected final java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode> cache
protected final java.util.Map<java.lang.String,java.util.Set<java.lang.String>> tagsForUrls
protected final java.util.concurrent.atomic.AtomicInteger queries
protected final java.util.concurrent.atomic.AtomicInteger hits
protected final java.util.concurrent.atomic.AtomicInteger puts
public com.fasterxml.jackson.databind.JsonNode get(java.lang.String url)
CacheManagerget in interface CacheManagerurl - The url that would be used to retrieve the response from Kontent.ai Delivery API.public void put(java.lang.String url,
com.fasterxml.jackson.databind.JsonNode jsonNode,
java.util.List<ContentItem> containedContentItems)
CacheManagerput in interface CacheManagerurl - the URL that was used to retrieve the response from the Kontent.ai Delivery API.jsonNode - the JsonNode created from the response from the Kontent.ai Delivery API.containedContentItems - (null allowed) can be used to inspect the original contents of the JsonNode and allow for precise cache invalidation (if implemented).public void invalidate(java.lang.String url)
public void invalidate(SimpleInMemoryCacheManager.CacheTag cacheTag)