Package com.flagsmith.interfaces
Interface FlagsmithCache
- All Known Implementing Classes:
FlagsmithCacheConfig.FlagsmithCacheImpl
public interface FlagsmithCache
Here are the fields we expose from the cache to outside this library.
-
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.
-
Method Details
-
cleanUp
void cleanUp()Performs any pending maintenance operations needed by the cache. -
invalidateAll
void invalidateAll()Discards all entries in the cache. -
invalidate
Discards any cached value for key userId.- Parameters:
userId- an id of the user
-
estimatedSize
long estimatedSize()Returns 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.- Returns:
- the estimated size
-
stats
com.github.benmanes.caffeine.cache.stats.CacheStats stats()Returns 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.- Returns:
- stats object
-
getIfPresent
Returns 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.- Parameters:
key- a key to retrieve value for- Returns:
- flags and traits in cache or null
-
getEnvFlagsCacheKey
String getEnvFlagsCacheKey()Returns 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.
- Returns:
- string
-
getIdentityFlagsCacheKey
Returns the cache key for a given identity.- Returns:
- string
-
getCache
Returns the Cache instance.
-