API Reference
Control APIs
Create Cache
Creates a cache with provided name
Attributes:
| Name | Type | Description |
|---|---|---|
| cacheName | String | Name of the cache to be created. |
Delete Cache
Deletes a cache
Attributes:
| Name | Type | Description |
|---|---|---|
| cacheName | String | Name of the cache to be deleted. |
List Caches
Lists all caches for the provided auth token.
| Name | Type | Description |
|---|---|---|
| nextToken | String | Token for pagination of caches. |
Data APIs
Set
Sets the value in cache with a given Time To Live (TTL) seconds. If a value for this key is already present it will be replaced by the new value.
| Name | Type | Description |
|---|---|---|
| cacheName | String | Name of the cache. |
| key | []Byte | The key under which the value is to be added. |
| value | []Byte | The value to be stored. |
| ttlSeconds | int | Time to Live for the item in Cache. |
- JavaScript
- Python
- Java
- Go
- C#
- Rust
- CLI
const authToken="eyJhbGc.MyTestToken";
const defaultTTL = 300;
const momento = new SimpleCacheClient(authToken, defaultTtl);
momento.set('test-cache', 'test-key', 'test-value');
import momento.simple_cache_client as scc
_MOMENTO_AUTH_TOKEN = "eyJhbGc.MyTestToken"
_ITEM_DEFAULT_TTL_SECONDS = 300
with scc.init(_MOMENTO_AUTH_TOKEN, _ITEM_DEFAULT_TTL_SECONDS) as cache_client:
cache_client.set('test-cache', 'test-key', 'test-value')
String MOMENTO_AUTH_TOKEN = "eyJhbGc.MyTestToken";
int DEFAULT_ITEM_TTL_SECONDS = 300;
SimpleCacheClient simpleCacheClient = SimpleCacheClient
.builder(MOMENTO_AUTH_TOKEN, DEFAULT_ITEM_TTL_SECONDS)
.build()
simpleCacheClient.set('test-cache', 'test-key', 'test-value');
const (
authToken = "eyJhbGc.MyTestToken"
itemDefaultTtlSeconds = 300
)
client, err := momento.NewSimpleCacheClient(authToken, itemDefaultTtlSeconds)
if err != nil {
panic(err)
}
_, err = client.Set(&CacheSetRequest{
CacheName: "test-cache",
Key: "test-key",
Value: "test-value",
})
uint DEFAULT_TTL_SECONDS = 300;
String MOMENTO_AUTH_TOKEN = "eyJhbGc.MyTestToken";
using SimpleCacheClient client = new SimpleCacheClient(MOMENTO_AUTH_TOKEN, DEFAULT_TTL_SECONDS);
client.Set("test-cache", "test-key", "test-value");
let auth_token = "eyJhbGc.MyTestToken";
let item_default_ttl_seconds = 300;
let mut cache_client = SimpleCacheClientBuilder::new(
auth_token,
NonZeroU64::new(item_default_ttl_seconds).unwrap(),
)
.unwrap()
.build();
let cache_name = String::from("cache");
let key = String::from("my_key");
let value = String::from("my_value");
cache_client
.set(&cache_name, key.clone(), value.clone(), None)
.await
.unwrap();
momento cache set --key test-key --value test-value
Get
Get the cache value stored for the given key.
| Name | Type | Description |
|---|---|---|
| cacheName | String | Name of the cache. |
| key | []Byte | The key under which the value is to be added. |
- JavaScript
- Python
- Java
- Go
- C#
- Rust
- CLI
const authToken="eyJhbGc.MyTestToken";
const defaultTTL = 300;
const momento = new SimpleCacheClient(authToken, defaultTtl);
momento.get('test-cache', 'test-key');
import momento.simple_cache_client as scc
_MOMENTO_AUTH_TOKEN = "eyJhbGc.MyTestToken"
_ITEM_DEFAULT_TTL_SECONDS = 300
with scc.init(_MOMENTO_AUTH_TOKEN, _ITEM_DEFAULT_TTL_SECONDS) as cache_client:
cache_client.get('test-cache', 'test-key')
String MOMENTO_AUTH_TOKEN = "eyJhbGc.MyTestToken";
int DEFAULT_ITEM_TTL_SECONDS = 300;
SimpleCacheClient simpleCacheClient = SimpleCacheClient
.builder(MOMENTO_AUTH_TOKEN, DEFAULT_ITEM_TTL_SECONDS)
.build()
simpleCacheClient.get('test-cache', 'test-key');
const (
authToken = "eyJhbGc.MyTestToken"
itemDefaultTtlSeconds = 300
)
client, err := momento.NewSimpleCacheClient(authToken, itemDefaultTtlSeconds)
if err != nil {
panic(err)
}
_, err = client.Get(&CacheSetRequest{
CacheName: "test-cache",
Key: "test-key",
})
uint DEFAULT_TTL_SECONDS = 300;
String MOMENTO_AUTH_TOKEN = "eyJhbGc.MyTestToken";
using SimpleCacheClient client = new SimpleCacheClient(MOMENTO_AUTH_TOKEN, DEFAULT_TTL_SECONDS);
client.Get("test-cache", "test-key");
let auth_token = "eyJhbGc.MyTestToken";
let item_default_ttl_seconds = 300;
let mut cache_client = SimpleCacheClientBuilder::new(
auth_token,
NonZeroU64::new(item_default_ttl_seconds).unwrap(),
)
.unwrap()
.build();
let cache_name = String::from("cache");
let key = String::from("my_key");
let value = String::from("my_value");
cache_client
.get(&cache_name, key.clone())
.await
.unwrap();
momento cache get --key test-key --value test-value
Delete
Delete the cache value stored for the given key.
| Name | Type | Description |
|---|---|---|
| cacheName | String | Name of the cache. |
| key | []Byte | The key under which the value is to be deleted. |
- JavaScript
- Python
- Java
- Go
- C#
- Rust
- CLI
const authToken="eyJhbGc.MyTestToken";
const defaultTTL = 300;
const momento = new SimpleCacheClient(authToken, defaultTtl);
momento.get('test-cache', 'test-key');
import momento.simple_cache_client as scc
_MOMENTO_AUTH_TOKEN = "eyJhbGc.MyTestToken"
_ITEM_DEFAULT_TTL_SECONDS = 300
with scc.init(_MOMENTO_AUTH_TOKEN, _ITEM_DEFAULT_TTL_SECONDS) as cache_client:
cache_client.delete('test-cache', 'test-key')
String MOMENTO_AUTH_TOKEN = "eyJhbGc.MyTestToken";
int DEFAULT_ITEM_TTL_SECONDS = 300;
SimpleCacheClient simpleCacheClient = SimpleCacheClient
.builder(MOMENTO_AUTH_TOKEN, DEFAULT_ITEM_TTL_SECONDS)
.build()
simpleCacheClient.delete('test-cache', 'test-key');
const (
authToken = "eyJhbGc.MyTestToken"
itemDefaultTtlSeconds = 300
)
client, err := momento.NewSimpleCacheClient(authToken, itemDefaultTtlSeconds)
if err != nil {
panic(err)
}
_, err = client.Delete(&CacheSetRequest{
CacheName: "test-cache",
Key: "test-key",
})
uint DEFAULT_TTL_SECONDS = 300;
String MOMENTO_AUTH_TOKEN = "eyJhbGc.MyTestToken";
using SimpleCacheClient client = new SimpleCacheClient(MOMENTO_AUTH_TOKEN, DEFAULT_TTL_SECONDS);
client.Delete("test-cache", "test-key");
let auth_token = "eyJhbGc.MyTestToken";
let item_default_ttl_seconds = 300;
let mut cache_client = SimpleCacheClientBuilder::new(
auth_token,
NonZeroU64::new(item_default_ttl_seconds).unwrap(),
)
.unwrap()
.build();
let cache_name = String::from("cache");
let key = String::from("my_key");
let value = String::from("my_value");
cache_client
.delete(&cache_name, key.clone())
.await
.unwrap();
momento cache delete --key test-key --value test-value