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
    void cleanUp()
    Performs any pending maintenance operations needed by the cache.
    long estimatedSize()
    Returns the approximate number of entries in this cache.
    com.github.benmanes.caffeine.cache.Cache<String,​Flags> getCache()
    Returns the Cache instance.
    String getEnvFlagsCacheKey()
    Returns the environment level flags/traits cache key.
    String getIdentityFlagsCacheKey​(String identifier, boolean isTransient)
    Returns the cache key for a given identity.
    Flags getIfPresent​(String key)
    Returns the value associated with key in this cache, or null if there is no cached value for key.
    void invalidate​(String userId)
    Discards any cached value for key userId.
    void invalidateAll()
    Discards all entries in the cache.
    com.github.benmanes.caffeine.cache.stats.CacheStats stats()
    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

      void invalidate​(String userId)
      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

      Flags getIfPresent​(String key)
      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

      String getIdentityFlagsCacheKey​(String identifier, boolean isTransient)
      Returns the cache key for a given identity.
      Returns:
      string
    • getCache

      com.github.benmanes.caffeine.cache.Cache<String,​Flags> getCache()
      Returns the Cache instance.