Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cache option :default_key_generator to change the key generator at compile time #126

Closed
cabol opened this issue Jun 19, 2021 · 0 comments

Comments

@cabol
Copy link
Owner

cabol commented Jun 19, 2021

When using declarative caching, by default, the key generator is set to Nebulex.Caching.SimpleKeyGenerator. But we should be able to change it at compile time with the option :default_key_generator, like so:

defmodule MyApp.Cache do
  use Nebulex.Cache,
    otp_app: :my_app,
    adapter: Nebulex.Adapters.Local,
    default_key_generator: MyApp.Cache.CustomKeyGenerator
end

This will allow changing the default key generator globally avoiding passing it on every caching annotation. However, the annotation :key_generator option remains and can be used at any time to override the default generator.

The suggestion came from issue #122

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

No branches or pull requests

1 participant