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 Details

    • FlagsmithCacheImpl

      public FlagsmithCacheImpl​(com.github.benmanes.caffeine.cache.Cache<String,​Flags> cache, String envFlagsCacheKey)
    • FlagsmithCacheImpl

      public FlagsmithCacheImpl​(com.github.benmanes.caffeine.cache.Cache<String,​Flags> cache)
  • Method Details

    • cleanUp

      public void cleanUp()
      Description copied from interface: FlagsmithCache
      Performs any pending maintenance operations needed by the cache.
      Specified by:
      cleanUp in interface FlagsmithCache
    • invalidateAll

      public void invalidateAll()
      Description copied from interface: FlagsmithCache
      Discards all entries in the cache.
      Specified by:
      invalidateAll in interface FlagsmithCache
    • invalidate

      public void invalidate​(String userId)
      Description copied from interface: FlagsmithCache
      Discards any cached value for key userId.
      Specified by:
      invalidate in interface FlagsmithCache
      Parameters:
      userId - an id of the user
    • estimatedSize

      public long estimatedSize()
      Description copied from interface: FlagsmithCache
      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.
      Specified by:
      estimatedSize in interface FlagsmithCache
      Returns:
      the estimated size
    • stats

      public com.github.benmanes.caffeine.cache.stats.CacheStats stats()
      Description copied from interface: FlagsmithCache
      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.
      Specified by:
      stats in interface FlagsmithCache
      Returns:
      stats object
    • getIfPresent

      public Flags getIfPresent​(String key)
      Description copied from interface: FlagsmithCache
      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.
      Specified by:
      getIfPresent in interface FlagsmithCache
      Parameters:
      key - a key to retrieve value for
      Returns:
      flags and traits in cache or null
    • getEnvFlagsCacheKey

      public String getEnvFlagsCacheKey()
      Description copied from interface: FlagsmithCache
      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.

      Specified by:
      getEnvFlagsCacheKey in interface FlagsmithCache
      Returns:
      string
    • getIdentityFlagsCacheKey

      public String getIdentityFlagsCacheKey​(String identifier, boolean isTransient)
      Description copied from interface: FlagsmithCache
      Returns the cache key for a given identity.
      Specified by:
      getIdentityFlagsCacheKey in interface FlagsmithCache
      Returns:
      string
    • getCache

      public com.github.benmanes.caffeine.cache.Cache<String,​Flags> getCache()
      Description copied from interface: FlagsmithCache
      Returns the Cache instance.
      Specified by:
      getCache in interface FlagsmithCache