Skip to content

momentohq/client-sdk-elixir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo

project status project stability

Momento Elixir Client Library

Momento Cache is a fast, simple, pay-as-you-go caching solution without any of the operational overhead required by traditional caching solutions. This repo contains the source code for the Momento Elixir client library.

To get started with Momento you will need a Momento Auth Token. You can get one from the Momento Console.

Packages

The Momento Elixir SDK is available on Hex.

Usage

alias Momento.CacheClient

config = Momento.Configurations.Laptop.latest()
credential_provider = Momento.Auth.CredentialProvider.from_env_var!("MOMENTO_AUTH_TOKEN")
default_ttl_seconds = 60.0
client = CacheClient.create!(config, credential_provider, default_ttl_seconds)

cache_name = "cache"

case CacheClient.create_cache(client, cache_name) do
  {:ok, _} -> :ok
  :already_exists -> :ok
  {:error, error} -> raise error
end

{:ok, _} = CacheClient.set(client, cache_name, "foo", "bar")

case CacheClient.get(client, cache_name, "foo") do
  {:ok, hit} -> IO.puts("Got value: #{hit.value}")
  :miss -> :ok
  {:error, error} -> raise error
end

Getting Started and Documentation

Documentation is available on the Momento Docs website.

Examples

Working example projects, with all required build configuration files, are available in the examples subdirectory.

Developing

If you are interested in contributing to the SDK, please see the CONTRIBUTING docs.


For more info, visit our website at https://gomomento.com!