public static class FlagsmithCacheConfig.Builder extends Object
| Modifier and Type | Method and Description |
|---|---|
FlagsmithCacheConfig |
build() |
FlagsmithCacheConfig.Builder |
enableEnvLevelCaching(@NonNull String envFlagsCacheKey)
Enables caching for environment level flags.
|
FlagsmithCacheConfig.Builder |
expireAfterAccess(int duration,
TimeUnit timeUnit)
Specifies that each entry should be automatically removed from the cache once a fixed
duration has elapsed after the entry's creation, the most recent replacement of its value, or
its last read.
|
FlagsmithCacheConfig.Builder |
expireAfterWrite(int duration,
TimeUnit timeUnit)
Specifies that each entry should be automatically removed from the cache once a fixed
duration has elapsed after the entry's creation, or the most recent replacement of its
value.
|
FlagsmithCacheConfig.Builder |
maxSize(int maxSize)
Specifies the maximum number of entries the cache may contain.
|
FlagsmithCacheConfig.Builder |
recordStats()
Enables the accumulation of CacheStats during the operation of the cache.
|
public FlagsmithCacheConfig.Builder expireAfterWrite(int duration, TimeUnit timeUnit)
duration - an integer matching the time unit.timeUnit - minutes, seconds, etc.public FlagsmithCacheConfig.Builder expireAfterAccess(int duration, TimeUnit timeUnit)
duration - an integer matching the time unit.timeUnit - minutes, seconds, etc.public FlagsmithCacheConfig.Builder maxSize(int maxSize)
As the cache size grows close to the maximum, the cache evicts entries that are less likely to be used again.
For example, the cache may evict an entry because it hasn't been used recently or very often.
maxSize - size. When size is zero, elements will be evicted immediately after being
loaded into the cache. This can be useful in testing, or to disable caching
temporarily without a code change.public FlagsmithCacheConfig.Builder recordStats()
Without this Cache.stats() will return zero for all statistics. Note that recording statistics requires bookkeeping to be performed with each operation, and thus imposes a performance penalty on cache operation.
public FlagsmithCacheConfig.Builder enableEnvLevelCaching(@NonNull @NonNull String envFlagsCacheKey)
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 is required to ensure the programmer chooses an environment-level-key that does not conflict with user identifiers.
IMPORTANT: make sure you set an environment key that will never match a user identifier.
Otherwise, the cache will not be able to distinguish between the 2.
envFlagsCacheKey - key to use in the cache for environment level flagspublic FlagsmithCacheConfig build()
Copyright © 2022. All rights reserved.