Package com.flagsmith.config
Class FlagsmithCacheConfig.FlagsmithCacheImpl
java.lang.Object
com.flagsmith.config.FlagsmithCacheConfig.FlagsmithCacheImpl
- All Implemented Interfaces:
FlagsmithCache
- Enclosing class:
- FlagsmithCacheConfig
public class FlagsmithCacheConfig.FlagsmithCacheImpl extends Object implements FlagsmithCache
-
Constructor Summary
Constructors Constructor Description FlagsmithCacheImpl(com.github.benmanes.caffeine.cache.Cache<String,Flags> cache)FlagsmithCacheImpl(com.github.benmanes.caffeine.cache.Cache<String,Flags> cache, String envFlagsCacheKey) -
Method Summary
Modifier and Type Method Description voidcleanUp()Performs any pending maintenance operations needed by the cache.longestimatedSize()Returns the approximate number of entries in this cache.com.github.benmanes.caffeine.cache.Cache<String,Flags>getCache()Returns the Cache instance.StringgetEnvFlagsCacheKey()Returns the environment level flags/traits cache key.StringgetIdentityFlagsCacheKey(String identifier, boolean isTransient)Returns the cache key for a given identity.FlagsgetIfPresent(String key)Returns the value associated with key in this cache, or null if there is no cached value for key.voidinvalidate(String userId)Discards any cached value for key userId.voidinvalidateAll()Discards all entries in the cache.com.github.benmanes.caffeine.cache.stats.CacheStatsstats()Returns a current snapshot of this cache's cumulative statistics.
-
Constructor Details
-
FlagsmithCacheImpl
-
FlagsmithCacheImpl
-
-
Method Details
-
cleanUp
public void cleanUp()Description copied from interface:FlagsmithCachePerforms any pending maintenance operations needed by the cache.- Specified by:
cleanUpin interfaceFlagsmithCache
-
invalidateAll
public void invalidateAll()Description copied from interface:FlagsmithCacheDiscards all entries in the cache.- Specified by:
invalidateAllin interfaceFlagsmithCache
-
invalidate
Description copied from interface:FlagsmithCacheDiscards any cached value for key userId.- Specified by:
invalidatein interfaceFlagsmithCache- Parameters:
userId- an id of the user
-
estimatedSize
public long estimatedSize()Description copied from interface:FlagsmithCacheReturns the approximate number of entries in this cache. The value returned is an estimate; the actual count may differ if there are concurrent insertions or removals, or if some entries are pending removal due to expiration or weak/soft reference collection. In the case of stale entries this inaccuracy can be mitigated by performing a cleanUp() first.- Specified by:
estimatedSizein interfaceFlagsmithCache- Returns:
- the estimated size
-
stats
public com.github.benmanes.caffeine.cache.stats.CacheStats stats()Description copied from interface:FlagsmithCacheReturns a current snapshot of this cache's cumulative statistics. All statistics are initialized to zero, and are monotonically increasing over the lifetime of the cache.- Specified by:
statsin interfaceFlagsmithCache- Returns:
- stats object
-
getIfPresent
Description copied from interface:FlagsmithCacheReturns the value associated with key in this cache, or null if there is no cached value for key. It will not attempt to fetch flags from Flagsmith.- Specified by:
getIfPresentin interfaceFlagsmithCache- Parameters:
key- a key to retrieve value for- Returns:
- flags and traits in cache or null
-
getEnvFlagsCacheKey
Description copied from interface:FlagsmithCacheReturns the environment level flags/traits cache key.Flags for users are stored in the cache using the user-identifier as the cache key.
For environment level flags, you need to configure a key with the builder to enable caching environment flags.
This method returns the key you configured with the builder.
- Specified by:
getEnvFlagsCacheKeyin interfaceFlagsmithCache- Returns:
- string
-
getIdentityFlagsCacheKey
Description copied from interface:FlagsmithCacheReturns the cache key for a given identity.- Specified by:
getIdentityFlagsCacheKeyin interfaceFlagsmithCache- Returns:
- string
-
getCache
Description copied from interface:FlagsmithCacheReturns the Cache instance.- Specified by:
getCachein interfaceFlagsmithCache
-