Unleash.Cache (Unleash v5.1.2)

View Source

This module is a cache backed by an ETS table. We use it to allow for multiple threads to read the feature flag values concurrently on top of minimizing network calls

Summary

Functions

Will return all values currently stored in the cache

Will return the feature for the given name stored in the cache

Will return all features stored in the cache

Will create a new ETS table named :unleash_cache

Will upsert (create or update) the given features in the cache

Functions

get_all_feature_names(table_name \\ :unleash_cache)

Will return all values currently stored in the cache

get_feature(name, table_name \\ :unleash_cache)

Will return the feature for the given name stored in the cache

get_features(table_name \\ :unleash_cache)

Will return all features stored in the cache

init(existing_features \\ [], table_name \\ :unleash_cache)

Will create a new ETS table named :unleash_cache

upsert_features(features, table_name \\ :unleash_cache)

Will upsert (create or update) the given features in the cache

This will clear the existing peristed features to prevent stale reads

When Unleash.Config.allowed_features/0 is set, only features whose name is in that list are stored, keeping the cache minimal for services that use just a few flags. When it is nil (the default), every feature is cached.