Momento client-sdk-rust
⚠️ Experimental SDK ⚠️
Rust SDK for Momento is experimental and under active development. There could be non-backward compatible changes or removal in the future. Please be aware that you may need to update your source code with the current version of the SDK when its version gets upgraded.
Rust SDK for Momento, a serverless cache that automatically scales without any of the operational overhead required by traditional caching solutions.
Getting Started 🏃
Requirements
- A Momento Auth Token is required, you can generate one using the Momento CLI
Using Momento
use env;
use SimpleCacheClient;
// Initializing Momento
let auth_token = var.expect;
let item_default_ttl_seconds = 60
let mut cache_client = new.await.unwrap;
// Creating a cache named "cache"
let cache_name = Stringfrom;
cache_client.create_cache.await.unwrap
// Sets key with default TTL and get value with that key
let key = Stringfrom;
let value = Stringfrom;
cache_client.set.await.unwrap;
let result = cache_client.get.await.unwrap;
println!;
// Sets key with TTL of 5 seconds
cache_client.set.await.unwrap;
// Permanently deletes cache
cache_client.delete_cache.await.unwrap;
Running Tests ⚡
Doc and integration tests require an auth token for testing. Set the env var TEST_AUTH_TOKEN to
provide it.
Running unit tests:
cargo test --lib
Running doc tests:
TEST_AUTH_TOKEN=<auth token> cargo test --doc
Running integration tests:
TEST_AUTH_TOKEN=<auth token> cargo test --tests