Skip to content

Make cache adapter configurable via application config #208

Open
daniikpando wants to merge 1 commit intotompave:masterfrom
mono-colombia:master
Open

Make cache adapter configurable via application config #208
daniikpando wants to merge 1 commit intotompave:masterfrom
mono-colombia:master

Conversation

@daniikpando
Copy link

Motivation

There are cases where the current cache implementation doesn't cover all needs; for example, when you need custom logic within the cache layer, such as personalized logging, metrics, or key partitioning by umbrella apps (my case). Currently there's no way to swap the cache implementation without forking the library.

This change makes the cache adapter configurable so anyone can provide their implementation while keeping the default ETS-based cache.

No breaking changes

This is fully compatible. When no adapter is configured, the library defaults to the existing FunWithFlags.Store.Cache, so current users are not affected in any way.

Usage

To use a custom cache, simply implement the FunWithFlags.Store.Cache.Behaviour and configure it:

  config :fun_with_flags, :cache,
    enabled: true,
    ttl: 900,
    adapter: MyApp.CustomCache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant