Momento Cache
Mix.install([
{:gomomento, "~> 0.6"},
{:kino, "~> 0.14"}
])
Alias
alias Momento.CacheClient
Prepare client
api_key_input = Kino.Input.password("API_KEY")
config = Momento.Configurations.Laptop.latest()
credential_provider =
api_key_input
|> Kino.Input.read()
|> Momento.Auth.CredentialProvider.from_string!()
default_ttl_seconds = 60.0
client = CacheClient.create!(config, credential_provider, default_ttl_seconds)
Crate and list caches
cache_name = "cache"
CacheClient.create_cache(client, cache_name)
CacheClient.list_caches(client)
Set and get
CacheClient.set(client, cache_name, "foo", "bar")
CacheClient.get(client, cache_name, "foo")