Class CaffeineProxy
java.lang.Object
com.broadleafcommerce.common.extension.cache.caffeine.CaffeineProxy
public class CaffeineProxy
extends Object
implements com.github.benmanes.caffeine.cache.Cache<Object,Object>
A decorating proxy for Caffeine
Cache instances that transparently handles value
serialization and deserialization using a configured Serializer.
This implementation provides three primary benefits:
- Heap Optimization: By storing serialized byte arrays (typically via Apache Fury) instead of full object graphs, heap usage is significantly reduced (often 75%-90% smaller).
- Immutability Enforcement: Deserializing on every
getensures that callers receive a fresh copy of the data. This prevents "cache poisoning" where a caller might unintentionally mutate a shared object, which would otherwise impact subsequent cache lookups. - Efficient/Accurate Cache Sizes: Since we are serializing to a byte array, we can achieve very accurate cache member sizing and do so with an inexpensive byte array count
- Author:
- Jeff Fischer
-
Constructor Summary
ConstructorsConstructorDescriptionCaffeineProxy(com.github.benmanes.caffeine.cache.Cache<Object, Object> internalStore, Serializer serializer) -
Method Summary
Modifier and TypeMethodDescriptionasMap()voidcleanUp()longgetAllPresent(Iterable<?> keys) getIfPresent(Object key) longvoidinvalidate(Object key) voidvoidinvalidateAll(Iterable<?> keys) policy()voidvoidcom.github.benmanes.caffeine.cache.stats.CacheStatsstats()
-
Constructor Details
-
CaffeineProxy
public CaffeineProxy(com.github.benmanes.caffeine.cache.Cache<Object, Object> internalStore, Serializer serializer)
-
-
Method Details
-
getIfPresent
-
put
-
asMap
-
get
-
getAllPresent
-
getAll
-
putAll
-
invalidate
-
invalidateAll
-
invalidateAll
public void invalidateAll() -
estimatedSize
public long estimatedSize() -
stats
@NonNull public com.github.benmanes.caffeine.cache.stats.CacheStats stats() -
cleanUp
public void cleanUp() -
policy
-
getManualPutCount
public long getManualPutCount()
-