API reference for Momento Cache
Control APIs
These API methods are used to manage and control caches.
Create cache
Creates a cache with the provided name
Attributes:
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache to be created. |
- JavaScript
- Python
- Java
- Kotlin
- Go
- C#
- PHP
- Rust
- Elixir
- Swift
- Dart
const result = await cacheClient.createCache(cacheName);
switch (result.type) {
case CreateCacheResponse.AlreadyExists:
console.log(`Cache '${cacheName}' already exists`);
break;
case CreateCacheResponse.Success:
console.log(`Cache '${cacheName}' created`);
break;
case CreateCacheResponse.Error:
throw new Error(
`An error occurred while attempting to create cache '${cacheName}': ${result.errorCode()}: ${result.toString()}`
);
}
create_cache_response = await cache_client.create_cache("test-cache")
match create_cache_response:
case CreateCache.Success():
print("Cache 'test-cache' created")
case CreateCache.CacheAlreadyExists():
print("Cache 'test-cache' already exists.")
case CreateCache.Error() as error:
print(f"An error occurred while attempting to create cache 'test-cache': {error.message}")
final CacheCreateResponse response = cacheClient.createCache("test-cache").join();
if (response instanceof CacheCreateResponse.Success) {
System.out.println("Cache 'test-cache' created");
} else if (response instanceof CacheCreateResponse.Error error) {
if (error.getErrorCode() == MomentoErrorCode.ALREADY_EXISTS_ERROR) {
System.out.println("Cache 'test-cache' already exists");
} else {
throw new RuntimeException(
"An error occurred while attempting to create cache 'test-cache': "
+ error.getErrorCode(),
error);
}
}
when (val response = cacheClient.createCache("test-cache")) {
is CacheCreateResponse.Success -> println("Cache 'test-cache' created")
is CacheCreateResponse.AlreadyExists -> println("Cache 'test-cache' already exists")
is CacheCreateResponse.Error -> throw RuntimeException(
"An error occurred while attempting to create cache 'test-cache': ${response.errorCode}", response
)
}
_, err := client.CreateCache(ctx, &momento.CreateCacheRequest{
CacheName: cacheName,
})
if err != nil {
panic(err)
}
var result = await cacheClient.CreateCacheAsync("test-cache");
if (result is CreateCacheResponse.Success)
{
Console.WriteLine("Cache 'test-cache' created");
}
else if (result is CreateCacheResponse.CacheAlreadyExists)
{
Console.WriteLine("Cache 'test-cache' already exists");
}
else if (result is CreateCacheResponse.Error error)
{
throw new Exception($"An error occurred while attempting to create cache 'test-cache': {error.ErrorCode}: {error}");
}
$create_cache_response = $cache_client->createCache($cache_name);
if ($create_cache_response->asSuccess()) {
print("Cache $cache_name created\n");
} elseif ($create_cache_response->asAlreadyExists()) {
print("Cache $cache_name already exists\n");
} elseif ($err = $create_cache_response->asError()) {
print("An error occurred while attempting to create $cache_name: {$err->errorCode()} - {$err->message()}\n");
}
match cache_client.create_cache(cache_name).await? {
CreateCacheResponse::Created => println!("Cache {} created", cache_name),
CreateCacheResponse::AlreadyExists => println!("Cache {} already exists", cache_name),
}
case Momento.CacheClient.create_cache(client, "test-cache") do
{:ok, _} ->
IO.puts("Cache 'test-cache' created")
:already_exists ->
:ok
{:error, error} ->
IO.puts(
"An error occurred while attempting to create cache 'test-cache': #{error.error_code}"
)
raise error
end
let result = await cacheClient.createCache(cacheName: cacheName)
switch result {
case .alreadyExists(_):
print("Cache already exists!")
case .success(_):
print("Successfully created the cache!")
case .error(let err):
print("Unable to create the cache: \(err)")
exit(1)
}
final result = await cacheClient.createCache("test-cache");
switch (result) {
case CreateCacheAlreadyExists():
print("Cache already exists");
case CreateCacheError():
print("Error creating cache: $result");
case CreateCacheSuccess():
print("Successfully created the cache");
}
Delete cache
Deletes a cache
Attributes:
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache to be deleted. |
- JavaScript
- Python
- Java
- Kotlin
- Go
- C#
- PHP
- Rust
- Elixir
- Swift
- Dart
const result = await cacheClient.deleteCache(cacheName);
switch (result.type) {
case DeleteCacheResponse.Success:
console.log(`Cache '${cacheName}' deleted`);
break;
case DeleteCacheResponse.Error:
throw new Error(
`An error occurred while attempting to delete cache '${cacheName}': ${result.errorCode()}: ${result.toString()}`
);
}
delete_cache_response = await cache_client.delete_cache("test-cache")
match delete_cache_response:
case DeleteCache.Success():
print("Cache 'test-cache' deleted")
case DeleteCache.Error() as error:
raise Exception(f"An error occurred while attempting to delete 'test-cache': {error.message}")
final CacheDeleteResponse response = cacheClient.deleteCache("test-cache").join();
if (response instanceof CacheDeleteResponse.Success) {
System.out.println("Cache 'test-cache' deleted");
} else if (response instanceof CacheDeleteResponse.Error error) {
throw new RuntimeException(
"An error occurred while attempting to delete cache 'test-cache': "
+ error.getErrorCode(),
error);
}
when (val response = cacheClient.deleteCache("test-cache")) {
is CacheDeleteResponse.Success -> println("Cache 'test-cache' deleted")
is CacheDeleteResponse.Error -> throw RuntimeException(
"An error occurred while attempting to delete cache 'test-cache': ${response.errorCode}", response
)
}
_, err := client.DeleteCache(ctx, &momento.DeleteCacheRequest{
CacheName: cacheName,
})
if err != nil {
panic(err)
}
var result = await cacheClient.DeleteCacheAsync("test-cache");
if (result is DeleteCacheResponse.Success)
{
Console.WriteLine("Cache 'test-cache' deleted");
}
else if (result is DeleteCacheResponse.Error error)
{
throw new Exception($"An error occurred while attempting to delete cache 'test-cache': {error.ErrorCode}: {error}");
}
$delete_cache_response = $cache_client->deleteCache($cache_name);
if ($err = $delete_cache_response->asError()) {
print("An error occurred while attempting to delete $cache_name: {$err->errorCode()} - {$err->message()}\n");
} else {
print("Cache $cache_name deleted\n");
}
cache_client.delete_cache(cache_name).await?;
println!("Cache {} deleted", cache_name);
case Momento.CacheClient.delete_cache(client, "test-cache") do
{:ok, _} ->
IO.puts("Cache 'test-cache' deleted")
{:error, error} ->
IO.puts(
"An error occurred while attempting to delete cache 'test-cache': #{error.error_code}"
)
raise error
end
let result = await cacheClient.deleteCache(cacheName: cacheName)
switch result {
case .success(let success):
print("Successfully deleted the cache")
case .error(let err):
print("Unable to delete cache: \(err)")
exit(1)
}
final result = await cacheClient.deleteCache("test-cache");
switch (result) {
case DeleteCacheError():
print("Error deleting cache: $result");
exit(1);
case DeleteCacheSuccess():
print("Successfully deleted cache");
}
List caches
Lists all caches
- JavaScript
- Python
- Java
- Kotlin
- Go
- C#
- PHP
- Rust
- Elixir
- Swift
- Dart
const result = await cacheClient.listCaches();
switch (result.type) {
case ListCachesResponse.Success:
console.log(
`Caches:\n${result
.getCaches()
.map(c => c.getName())
.join('\n')}\n\n`
);
break;
case ListCachesResponse.Error:
throw new Error(`An error occurred while attempting to list caches: ${result.errorCode()}: ${result.toString()}`);
}
print("Listing caches:")
list_caches_response = await cache_client.list_caches()
match list_caches_response:
case ListCaches.Success() as success:
for cache_info in success.caches:
print(f"- {cache_info.name!r}")
case ListCaches.Error() as error:
raise Exception(f"An error occurred while attempting to list caches: {error.message}")
final CacheListResponse response = cacheClient.listCaches().join();
if (response instanceof CacheListResponse.Success success) {
final String caches =
success.getCaches().stream().map(CacheInfo::name).collect(Collectors.joining("\n"));
System.out.println("Caches:\n" + caches);
} else if (response instanceof CacheListResponse.Error error) {
throw new RuntimeException(
"An error occurred while attempting to list caches: " + error.getErrorCode(), error);
}
when (val response: CacheListResponse = cacheClient.listCaches()) {
is CacheListResponse.Success -> {
val caches: String = response.caches.joinToString("\n") { cacheInfo -> cacheInfo.name }
println("Caches:\n$caches")
}
is CacheListResponse.Error -> throw RuntimeException(
"An error occurred while attempting to list caches: ${response.errorCode}", response
)
}
resp, err := client.ListCaches(ctx, &momento.ListCachesRequest{})
if err != nil {
panic(err)
}
switch r := resp.(type) {
case *responses.ListCachesSuccess:
log.Printf("Found caches %+v\n", r.Caches())
}
var result = await cacheClient.ListCachesAsync();
if (result is ListCachesResponse.Success success)
{
Console.WriteLine($"Caches:\n{string.Join("\n", success.Caches.Select(c => c.Name))}\n\n");
}
else if (result is ListCachesResponse.Error error)
{
throw new Exception($"An error occurred while attempting to list caches: {error.ErrorCode}: {error}");
}
$list_caches_response = $cache_client->listCaches();
if ($success = $list_caches_response->asSuccess()) {
print("Found caches:\n");
foreach ($success->caches() as $cache) {
$cache_name = $cache->name();
print("- $cache_name\n");
}
} elseif ($err = $list_caches_response->asError()) {
print("An error occurred while attempting to list caches: {$err->errorCode()} - {$err->message()}\n");
}
let response = cache_client.list_caches().await?;
println!("Caches: {:#?}", response.caches);
case Momento.CacheClient.list_caches(client) do
{:ok, result} ->
IO.puts("Caches:")
IO.inspect(result.caches)
{:error, error} ->
IO.puts("An error occurred while attempting to list caches: #{error.error_code}")
raise error
end
let result = await cacheClient.listCaches()
switch result {
case .success(let success):
print("Successfully fetched list of caches: \(success.caches.map { $0.name })")
case .error(let err):
print("Unable to fetch list of caches: \(err)")
exit(1)
}
final result = await cacheClient.listCaches();
switch (result) {
case ListCachesError():
print("Error listing caches: $result");
case ListCachesSuccess():
print("Successfully listed caches: ${result.cacheNames}");
}
Flush cache
Flushes all data from a cache
Attributes:
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache to be flushed. |
- JavaScript
- Java
- C#
- Rust
const result = await cacheClient.flushCache(cacheName);
switch (result.type) {
case FlushCacheResponse.Success:
console.log(`Cache '${cacheName}' flushed`);
break;
case FlushCacheResponse.Error:
throw new Error(
`An error occurred while attempting to flush cache '${cacheName}': ${result.errorCode()}: ${result.toString()}`
);
}
final CacheFlushResponse response = cacheClient.flushCache("test-cache").join();
if (response instanceof CacheFlushResponse.Success) {
System.out.println("Cache 'test-cache' flushed");
} else if (response instanceof CacheFlushResponse.Error error) {
throw new RuntimeException(
"An error occurred while attempting to flush cache 'test-cache': " + error.getErrorCode(),
error);
}
var result = await cacheClient.FlushCacheAsync("test-cache");
if (result is FlushCacheResponse.Success)
{
Console.WriteLine("Cache 'test-cache' flushed");
}
else if (result is FlushCacheResponse.Error error)
{
throw new Exception($"An error occurred while attempting to flush cache 'test-cache': {error.ErrorCode}: {error}");
}
cache_client.flush_cache(cache_name.to_string()).await?;
println!("Cache {} flushed", cache_name);
While you could use Delete Cache, then Create Cache to mimic this, the FlushCache API keeps the settings and only deletes the data in the cache.
Data APIs
These API methods are used to directly interact with data in a cache.
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 regardless of the previous value's data type.
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
- Kotlin
- Go
- C#
- PHP
- Rust
- Elixir
- Swift
- Dart
const result = await cacheClient.set(cacheName, 'test-key', 'test-value');
switch (result.type) {
case CacheSetResponse.Success:
console.log("Key 'test-key' stored successfully");
break;
case CacheSetResponse.Error:
throw new Error(
`An error occurred while attempting to store key 'test-key' in cache '${cacheName}': ${result.errorCode()}: ${result.toString()}`
);
}
set_response = await cache_client.set("test-cache", "test-key", "test-value")
match set_response:
case CacheSet.Success():
print("Key 'test-key' stored successfully")
case CacheSet.Error() as error:
raise Exception(
f"An error occurred while attempting to store key 'test-key' in cache 'test-cache': {error.message}"
)
final SetResponse response = cacheClient.set("test-cache", "test-key", "test-value").join();
if (response instanceof SetResponse.Success) {
System.out.println("Key 'test-key' stored successfully");
} else if (response instanceof SetResponse.Error error) {
throw new RuntimeException(
"An error occurred while attempting to store key 'test-key' in cache 'test-cache': "
+ error.getErrorCode(),
error);
}
when (val response = cacheClient.set("test-cache", "test-key", "test-value")) {
is SetResponse.Success -> println("Key 'test-key' stored successfully")
is SetResponse.Error -> throw RuntimeException(
"An error occurred while attempting to store key 'test-key' in cache 'test-cache': ${response.errorCode}",
response
)
}
key := uuid.NewString()
value := uuid.NewString()
log.Printf("Setting key: %s, value: %s\n", key, value)
_, err := client.Set(ctx, &momento.SetRequest{
CacheName: cacheName,
Key: momento.String(key),
Value: momento.String(value),
Ttl: time.Duration(9999),
})
if err != nil {
var momentoErr momento.MomentoError
if errors.As(err, &momentoErr) {
if momentoErr.Code() != momento.TimeoutError {
// this would represent a client-side timeout, and you could fall back to your original data source
} else {
panic(err)
}
}
}
var result = await cacheClient.SetAsync("test-cache", "test-key", "test-value");
if (result is CacheSetResponse.Success)
{
Console.WriteLine("Key 'test-key' stored successfully");
}
else if (result is CacheSetResponse.Error error)
{
throw new Exception($"An error occurred while attempting to store key 'test-key' in cache 'test-cache': {error.ErrorCode}: {error}");
}
$set_response = $cache_client->set($cache_name, "test-key", "test-value");
if ($set_response->asSuccess()) {
print("Key $cache_name stored successfully\n");
} elseif ($err = $set_response->asError()) {
print("An error occurred while attempting to store $cache_name: {$err->errorCode()} - {$err->message()}\n");
}
cache_client.set(cache_name, "key", "value").await?;
println!("Value stored");
case Momento.CacheClient.set(client, "test-cache", "test-key", "test-value") do
{:ok, _} ->
IO.puts("Key 'test-key' stored successfully")
{:error, error} ->
IO.puts(
"An error occurred while attempting to store key 'test-key' in cache 'test-cache': #{error.error_code}"
)
raise error
end
let result = await cacheClient.set(
cacheName: cacheName,
key: "key",
value: "value"
)
switch result {
case .success(_):
print("Successfully set item in the cache")
case .error(let err):
print("Unable to set item in the cache: \(err)")
exit(1)
}
final result = await cacheClient.set("test-cache", "test-key", "test-value");
switch (result) {
case SetError():
print("Error setting key: $result");
exit(1);
case SetSuccess():
print("Successfully set item in the cache");
}
SetBatch
Sets multiple key-value pairs in a cache with a given Time To Live (TTL) seconds. If a value for a key is already present, it will be replaced by the new value regardless of the previous value's data type.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
items | { String/[]Byte : String/[]Byte } | The mapping of keys to values that should be stored |
ttlSeconds | int | Time to Live for the items in Cache. |
- JavaScript
- Go
const values = new Map<string, string>([
['abc', '123'],
['xyz', '321'],
['123', 'xyz'],
['321', 'abc'],
]);
const result = await cacheClient.setBatch(cacheName, values);
switch (result.type) {
case CacheSetBatchResponse.Success:
console.log('Keys and values stored successfully');
break;
case CacheSetBatchResponse.Error:
throw new Error(
`An error occurred while attempting to batch set in cache '${cacheName}': ${result.errorCode()}: ${result.toString()}`
);
}
resp, err := client.SetBatch(ctx, &momento.SetBatchRequest{
CacheName: cacheName,
Items: []momento.BatchSetItem{
{
Key: momento.String("key1"),
Value: momento.String("value1"),
},
{
Key: momento.String("key2"),
Value: momento.String("value2"),
},
},
})
if err != nil {
panic(err)
}
switch resp.(type) {
case *responses.SetBatchSuccess:
log.Printf("Successfully set keys in cache\n")
}
Method response object
- Success
results()
: CacheSet.Response[]
- Error
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 retrieved. |
- JavaScript
- Python
- Java
- Kotlin
- Go
- C#
- PHP
- Rust
- Elixir
- Swift
- Dart
const getResponse = await cacheClient.get(cacheName, 'test-key');
// simplified style; assume the value was found
console.log(`cache hit: ${getResponse.value()!}`);
// pattern-matching style; safer for production code
switch (getResponse.type) {
case CacheGetResponse.Hit:
console.log(`Retrieved value for key 'test-key': ${getResponse.valueString()}`);
break;
case CacheGetResponse.Miss:
console.log(`Key 'test-key' was not found in cache '${cacheName}'`);
break;
case CacheGetResponse.Error:
throw new Error(
`An error occurred while attempting to get key 'test-key' from cache '${cacheName}': ${getResponse.errorCode()}: ${getResponse.toString()}`
);
}
get_response = await cache_client.get("test-cache", "test-key")
match get_response:
case CacheGet.Hit() as hit:
print(f"Retrieved value for key 'test-key': {hit.value_string}")
case CacheGet.Miss():
print("Key 'test-key' was not found in cache 'test-cache'")
case CacheGet.Error() as error:
raise Exception(
f"An error occurred while attempting to get key 'test-key' from cache 'test-cache': {error.message}"
)
final GetResponse response = cacheClient.get("test-cache", "test-key").join();
if (response instanceof GetResponse.Hit hit) {
System.out.println("Retrieved value for key 'test-key': " + hit.valueString());
} else if (response instanceof GetResponse.Miss) {
System.out.println("Key 'test-key' was not found in cache 'test-cache'");
} else if (response instanceof GetResponse.Error error) {
throw new RuntimeException(
"An error occurred while attempting to get key 'test-key' from cache 'test-cache': "
+ error.getErrorCode(),
error);
}
when (val response = cacheClient.get("test-cache", "test-key")) {
is GetResponse.Hit -> println("Retrieved value for key 'test-key': ${response.value}")
is GetResponse.Miss -> println("Key 'test-key' was not found in cache 'test-cache'")
is GetResponse.Error -> throw RuntimeException(
"An error occurred while attempting to get key 'test-key' from cache 'test-cache': ${response.errorCode}",
response
)
}
key := uuid.NewString()
resp, err := client.Get(ctx, &momento.GetRequest{
CacheName: cacheName,
Key: momento.String(key),
})
if err != nil {
panic(err)
}
switch r := resp.(type) {
case *responses.GetHit:
log.Printf("Lookup resulted in cache HIT. value=%s\n", r.ValueString())
case *responses.GetMiss:
log.Printf("Look up did not find a value key=%s\n", key)
}
var result = await cacheClient.GetAsync("test-cache", "test-key");
if (result is CacheGetResponse.Hit hit)
{
Console.WriteLine($"Retrieved value for key 'test-key': {hit.ValueString}");
}
else if (result is CacheGetResponse.Miss)
{
Console.WriteLine("Key 'test-key' was not found in cache 'test-cache'");
}
else if (result is CacheGetResponse.Error error)
{
throw new Exception($"An error occurred while attempting to get key 'test-key' from cache 'test-cache': {error.ErrorCode}: {error}");
}
$get_response = $cache_client->get($cache_name, "test-key");
if ($hit = $get_response->asHit()) {
print("Retrieved value for key 'test-key': {$hit->valueString()}\n");
} elseif ($get_response->asMiss()) {
print("Key 'test-key' was not found in cache $cache_name\n");
} elseif ($err = $get_response->asError()) {
print("An error occurred while attempting to get key 'test-key' from cache $cache_name: {$err->errorCode()} - {$err->message()}\n");
}
let response = cache_client.get(cache_name, "key").await?;
let _item: String = response.try_into().expect("I stored a string!");
case Momento.CacheClient.get(client, "test-cache", "test-key") do
{:ok, hit} ->
IO.puts("Retrieved value for key 'test-key': #{hit.value}")
:miss ->
IO.puts("Key 'test-key' was not found in cache 'test-cache'")
{:error, error} ->
IO.puts(
"An error occurred while attempting to get key 'test-key' from cache 'test-cache': #{error.error_code}"
)
raise error
end
let result = await cacheClient.get(
cacheName: cacheName,
key: "key"
)
switch result {
case .hit(let hit):
print("Cache hit: \(hit.valueString)")
case .miss(_):
print("Cache miss")
case .error(let err):
print("Unable to get item in the cache: \(err)")
exit(1)
}
final result = await cacheClient.get("test-cache", "test-key");
switch (result) {
case GetMiss():
print("Key was not found in cache.");
case GetError():
print("Error getting key: $result");
case GetHit():
print("Successfully got item from cache: ${result.value}");
}
GetBatch
Get the cache values stored for the given keys.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
keys | String[] / Bytes[] | The list of keys for which to retrieve values. |
- JavaScript
- Go
const keys = ['abc', 'xyz', '123', '321'];
const getBatchResponse = await cacheClient.getBatch(cacheName, keys);
// simplified style; assume the value was found
const values = getBatchResponse.values()!;
for (const key of keys) {
console.log(`Retrieved value for key '${key}': ${values[key]}`);
}
// pattern-matching style; safer for production code
switch (getBatchResponse.type) {
case CacheGetBatchResponse.Success: {
const values = getBatchResponse.values();
for (const key of keys) {
console.log(`Retrieved value for key '${key}': ${values[key]}`);
}
break;
}
case CacheGetBatchResponse.Error:
throw new Error(
`An error occurred while attempting to batch get in cache '${cacheName}': ${getBatchResponse.errorCode()}: ${getBatchResponse.toString()}`
);
}
resp, err := client.GetBatch(ctx, &momento.GetBatchRequest{
CacheName: cacheName,
Keys: []momento.Value{momento.String("key1"), momento.String("key2")},
})
if err != nil {
panic(err)
}
switch r := resp.(type) {
case *responses.GetBatchSuccess:
log.Printf("Found values %+v\n", r.ValueMap())
}
Method response object
- Success
values()
: Record<string, string>results()
: CacheGet.Response[]
- Error
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
- Kotlin
- Go
- C#
- PHP
- Rust
- Elixir
- Swift
- Dart
const result = await cacheClient.delete(cacheName, 'test-key');
switch (result.type) {
case CacheDeleteResponse.Success:
console.log("Key 'test-key' deleted successfully");
break;
case CacheDeleteResponse.Error:
throw new Error(
`An error occurred while attempting to delete key 'test-key' from cache '${cacheName}': ${result.errorCode()}: ${result.toString()}`
);
}
delete_response = await cache_client.delete("test-cache", "test-key")
match delete_response:
case CacheDelete.Success():
print("Key 'test-key' deleted successfully")
case CacheDelete.Error() as error:
raise Exception(
f"An error occurred while attempting to delete key 'test-key' from cache 'test-cache': {error.message}"
)
final DeleteResponse response = cacheClient.delete("test-cache", "test-key").join();
if (response instanceof DeleteResponse.Success) {
System.out.println("Key 'test-key' deleted successfully");
} else if (response instanceof DeleteResponse.Error error) {
throw new RuntimeException(
"An error occurred while attempting to delete key 'test-key' from cache 'test-cache': "
+ error.getErrorCode(),
error);
}
when (val response = cacheClient.delete("test-cache", "test-key")) {
is DeleteResponse.Success -> println("Key 'test-key' deleted successfully")
is DeleteResponse.Error -> throw RuntimeException(
"An error occurred while attempting to delete key 'test-key' from cache 'test-cache': ${response.errorCode}",
response
)
}
key := uuid.NewString()
_, err := client.Delete(ctx, &momento.DeleteRequest{
CacheName: cacheName,
Key: momento.String(key),
})
if err != nil {
panic(err)
}
var result = await cacheClient.DeleteAsync("test-cache", "test-key");
if (result is CacheDeleteResponse.Success)
{
Console.WriteLine("Key 'test-key' deleted successfully");
}
else if (result is CacheDeleteResponse.Error error)
{
throw new Exception($"An error occurred while attempting to delete key 'test-key' from cache 'test-cache': {error.ErrorCode}: {error}");
}
$delete_response = $cache_client->delete($cache_name, "test-key");
if ($delete_response->asSuccess()) {
print("Key 'test-key' deleted successfully\n");
} elseif ($err = $delete_response->asError()) {
print("An error occurred while attempting to delete key 'test-key' from cache $cache_name: {$err->errorCode()} - {$err->message()}\n");
}
cache_client.delete(cache_name, "key").await?;
println!("Value deleted");
case Momento.CacheClient.delete(client, "test-cache", "test-key") do
{:ok, _} ->
IO.puts("Key 'test-key' deleted successfully")
{:error, error} ->
IO.puts(
"An error occurred while attempting to delete key 'test-key' from cache 'test-cache': #{error.error_code}"
)
raise error
end
let result = await cacheClient.delete(
cacheName: cacheName,
key: "key"
)
switch result {
case .success(_):
print("Successfully deleted item in the cache")
case .error(let err):
print("Unable to delete item in the cache: \(err)")
exit(1)
}
final result = await cacheClient.delete("test-cache", "test-key");
switch (result) {
case DeleteError():
print("Error deleting key: $result");
exit(1);
case DeleteSuccess():
print("Successfully deleted key from cache");
}
Increment
Adds to the value of an item, if and only if the existing value is a UTF-8 string representing a base 10 integer. If the item does not exist, this method sets the item's value to the amount to increment by.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
key | String | The key under which the value is to be incremented. |
amount | Integer | The quantity to add to the value. May be positive, negative, or zero. Defaults to 1. |
The resulting incremented value must be between -9223372036854775808 and 9223372036854775807, ie. a signed 64-bit integer. If not, there will be an error response.
- JavaScript
- Java
- Go
- Rust
await cacheClient.set(cacheName, 'test-key', '10');
const result = await cacheClient.increment(cacheName, 'test-key', 1);
switch (result.type) {
case CacheIncrementResponse.Success:
console.log(`Key 'test-key' incremented successfully. New value in key test-key: ${result.valueNumber()}`);
break;
case CacheIncrementResponse.Error:
throw new Error(
`An error occurred while attempting to increment the value of key 'test-key' from cache '${cacheName}': ${result.errorCode()}: ${result.toString()}`
);
}
cacheClient.set("test-cache", "test-key", "10").join();
final IncrementResponse response = cacheClient.increment("test-cache", "test-key", 1).join();
if (response instanceof IncrementResponse.Success success) {
System.out.println(
"Key 'test-key' incremented successfully. New value in key test-key: "
+ success.valueNumber());
} else if (response instanceof IncrementResponse.Error error) {
throw new RuntimeException(
"An error occurred while attempting to increment the value of key 'test-key' from cache 'test-cache': "
+ error.getErrorCode(),
error);
}
resp, err := client.Increment(ctx, &momento.IncrementRequest{
CacheName: cacheName,
Field: momento.String("key"),
Amount: 1,
})
if err != nil {
panic(err)
}
switch r := resp.(type) {
case *responses.IncrementSuccess:
log.Printf("Incremented value is %d\n", r.Value())
}
let response = cache_client.increment(cache_name, "key", 1).await?;
println!("Value incremented to {}", response.value);
Ping
Sends a ping to the server. This API can be used for checking connectivity to confirm that the client can connect to the server successfully.
Method response object
- Success
- Error
See response objects for specific information.
ItemGetType
For a given key, returns the type (SCALAR, DICTIONARY, LIST, etc.) of the corresponding item, if it exists.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
key | String | Byte | Key whose item type should be returned. |
Method response object
- Cache hit
type()
: enum: SCALAR, DICTIONARY, SET, LIST, SORTED_SET
- Cache miss
- Cache error
See response objects for specific information.
- JavaScript
- Go
- Rust
const result = await cacheClient.itemGetType(cacheName, 'test-key');
switch (result.type) {
case CacheItemGetTypeResponse.Hit:
console.log(`Item type retrieved successfully: ${ItemType[result.itemType()]}`);
break;
case CacheItemGetTypeResponse.Miss:
console.log("Key 'test-key' was not found in cache '${cacheName}'");
break;
case CacheItemGetTypeResponse.Error:
throw new Error(
`An error occurred while attempting to get the type of key 'test-key' from cache '${cacheName}': ${result.errorCode()}: ${result.toString()}`
);
}
resp, err := client.ItemGetType(ctx, &momento.ItemGetTypeRequest{
CacheName: cacheName,
Key: momento.String("key"),
})
if err != nil {
panic(err)
}
switch r := resp.(type) {
case *responses.ItemGetTypeHit:
log.Printf("Type of item is %v\n", r.Type())
case *responses.ItemGetTypeMiss:
log.Printf("Item does not exist in cache\n")
}
let _item_type: ItemType = cache_client
.item_get_type(cache_name, "key")
.await?
.try_into()
.expect("Expected an item type!");
KeyExists
Checks if a provided key exists in the cache.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
key | String | Byte | Key which is to be checked for its existence in the cache. |
Method response object
- JavaScript
- Rust
const result = await cacheClient.keyExists(cacheName, 'test-key');
switch (result.type) {
case CacheKeyExistsResponse.Success:
console.log("Does 'test-key' exist in the cache?", result.exists());
break;
case CacheKeyExistsResponse.Error:
throw new Error(
`An error occurred while attempting to call keyExists on key 'test-key' in cache '${cacheName}': ${result.errorCode()}: ${result.toString()}`
);
}
let result = cache_client.key_exists(cache_name, "key").await?;
if result.exists {
println!("Key exists!");
} else {
println!("Key does not exist!");
}
KeysExist
Checks if provided keys exist in the cache.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
keys | String[] | Byte[] | Keys which are to be checked for their existence in the cache. |
Method response object
- JavaScript
- Go
- Rust
const result = await cacheClient.keysExist(cacheName, ['test-key1', 'test-key2']);
switch (result.type) {
case CacheKeysExistResponse.Success:
console.log("Do 'test-key1' and 'test-key2' exist in the cache?", result.exists());
break;
case CacheKeysExistResponse.Error:
throw new Error(
`An error occurred while attempting to call keysExist on keys 'test-key1' and 'test-key2' in cache '${cacheName}': ${result.errorCode()}: ${result.toString()}`
);
}
keys := []momento.Value{momento.String("key1"), momento.String("key2")}
resp, err := client.KeysExist(ctx, &momento.KeysExistRequest{
CacheName: cacheName,
Keys: keys,
})
if err != nil {
panic(err)
}
switch r := resp.(type) {
case *responses.KeysExistSuccess:
log.Printf("Does each key exist in cache?\n")
for _, exists := range r.Exists() {
log.Printf("key exists=%v\n", exists)
}
}
// Receive results as a HashMap
let result_map: HashMap<String, bool> = cache_client
.keys_exist(cache_name, vec!["key", "key1", "key2"])
.await?
.into();
println!("Do these keys exist? {:#?}", result_map);
// Or receive results as a Vec
let result_list: Vec<bool> = cache_client
.keys_exist(cache_name, vec!["key", "key1", "key2"])
.await?
.into();
println!("Do these keys exist? {:#?}", result_list);
SetIfAbsent
Do NOT use check-and-set (CAS) APIs such as SetIfPresent
with scalar or non-CAS APIs such as Set
or Delete
.
Doing so will result in undefined consistency behaviors. Use SetIfAbsent
instead with SetIfPresent
.
Associates the provided value to a cache item with a given key if the key does not already exist in the cache.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
key | String | Bytes | The key to be set. |
value | String | Bytes | The value to be stored. |
ttlSeconds | Duration | Time to Live for the item in Cache. |
Method response object
- Stored
- NotStored
- Error
See response objects for specific information.
- JavaScript
- Go
- Rust
const result = await cacheClient.setIfAbsent(cacheName, 'test-key', 'test-field');
switch (result.type) {
case CacheSetIfAbsentResponse.Stored:
console.log("Field 'test-field' set in key 'test-key'");
break;
case CacheSetIfAbsentResponse.NotStored:
console.log(`Key 'test-key' already exists in cache ${cacheName}, so we did not overwrite it`);
break;
case CacheSetIfAbsentResponse.Error:
throw new Error(
`An error occurred while attempting to call setIfAbsent for the key 'test-key' in cache cacheName: ${result.errorCode()}: ${result.toString()}`
);
}
resp, err := client.SetIfAbsent(ctx, &momento.SetIfAbsentRequest{
CacheName: cacheName,
Key: momento.String("key"),
Value: momento.String("value"),
})
if err != nil {
panic(err)
}
switch resp.(type) {
case *responses.SetIfAbsentStored:
log.Printf("Successfully set key in cache\n")
}
match cache_client
.set_if_absent(cache_name, "key", "value")
.await?
{
SetIfAbsentResponse::Stored => println!("Value stored"),
SetIfAbsentResponse::NotStored => println!("Value not stored"),
}
SetIfPresent
Do NOT use check-and-set (CAS) APIs such as SetIfPresent
with scalar or non-CAS APIs such as Set
or Delete
.
Doing so will result in undefined consistency behaviors. Use SetIfAbsent
instead with SetIfPresent
.
Associates the provided value to a cache item with a given key if the key already exists in the cache.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
key | String | Bytes | The key to be set. |
value | String | Bytes | The value to be stored. |
ttlSeconds | Duration | Time to Live for the item in Cache. |
Method response object
- Stored
- NotStored
- Error
See response objects for specific information.
- JavaScript
- Go
- Rust
const result = await cacheClient.setIfPresent(cacheName, 'test-key', 'test-field');
switch (result.type) {
case CacheSetIfPresentResponse.Stored:
console.log("Field 'test-field' set in key 'test-key'");
break;
case CacheSetIfPresentResponse.NotStored:
console.log(`Key 'test-key' does not exist in cache ${cacheName}, so we did not set the field`);
break;
case CacheSetIfPresentResponse.Error:
throw new Error(
`An error occurred while attempting to call setIfPresent for the key 'test-key' in cache cacheName: ${result.errorCode()}: ${result.toString()}`
);
}
resp, err := client.SetIfPresent(ctx, &momento.SetIfPresentRequest{
CacheName: cacheName,
Key: momento.String("key"),
Value: momento.String("value"),
})
if err != nil {
panic(err)
}
switch resp.(type) {
case *responses.SetIfPresentStored:
log.Printf("Successfully set key in cache\n")
}
match cache_client
.set_if_present(cache_name, "key", "value")
.await?
{
SetIfPresentResponse::Stored => println!("Value stored"),
SetIfPresentResponse::NotStored => println!("Value not stored"),
}
SetIfEqual
Do NOT use check-and-set (CAS) APIs such as SetIfEqual
with scalar or non-CAS APIs such as Set
or Delete
.
Doing so will result in undefined consistency behaviors. Use SetIfNotEqual
instead with SetIfEqual
.
Associates the provided value to a cache item with a given key if the key already exists in the cache and the value in the cache is equal to the value supplied for equal
.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
key | String | Bytes | The key to be set. |
value | String | Bytes | The value to be stored. |
equal | String | Bytes | The value to compare with. |
ttlSeconds | Duration | Time to Live for the item in Cache. |
Method response object
- Stored
- NotStored
- Error
See response objects for specific information.
- JavaScript
- Go
- Rust
const result = await cacheClient.setIfEqual(cacheName, 'test-key', 'test-field', 'value-to-check');
switch (result.type) {
case CacheSetIfEqualResponse.Stored:
console.log("Field 'test-field' set in key 'test-key'");
break;
case CacheSetIfEqualResponse.NotStored:
console.log("Value of key 'test-key' does not equal 'value-to-check', so we did not set the field");
break;
case CacheSetIfEqualResponse.Error:
throw new Error(
`An error occurred while attempting to call setIfEqual for the key 'test-key' in cache cacheName: ${result.errorCode()}: ${result.toString()}`
);
}
resp, err := client.SetIfEqual(ctx, &momento.SetIfEqualRequest{
CacheName: cacheName,
Key: momento.String("key"),
Value: momento.String("value"),
Equal: momento.String("current-value"),
})
if err != nil {
panic(err)
}
switch resp.(type) {
case *responses.SetIfEqualStored:
log.Printf("Successfully set key in cache\n")
}
match cache_client
.set_if_equal(cache_name, "key", "new-value", "cached-value")
.await?
{
SetIfEqualResponse::Stored => println!("Value stored"),
SetIfEqualResponse::NotStored => println!("Value not stored"),
}
SetIfNotEqual
Do NOT use check-and-set (CAS) APIs such as SetIfNotEqual
with scalar or non-CAS APIs such as Set
or Delete
.
Doing so will result in undefined consistency behaviors. Use SetIfEqual
instead with SetIfNotEqual
.
Associates the provided value to a cache item with a given key if the key does not already exist in the cache or the value in the cache is not equal to the value supplied for notEqual
.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
key | String | Bytes | The key to be set. |
value | String | Bytes | The value to be stored. |
notEqual | String | Bytes | The value to compare with. |
ttlSeconds | Duration | Time to Live for the item in Cache. |
Method response object
- Stored
- NotStored
- Error
See response objects for specific information.
- JavaScript
- Go
- Rust
const result = await cacheClient.setIfNotEqual(cacheName, 'test-key', 'test-field', 'value-to-check');
switch (result.type) {
case CacheSetIfNotEqualResponse.Stored:
console.log("Field 'test-field' set in key 'test-key'");
break;
case CacheSetIfNotEqualResponse.NotStored:
console.log("Value of key 'test-key' equals 'value-to-check', so we did not set the field");
break;
case CacheSetIfNotEqualResponse.Error:
throw new Error(
`An error occurred while attempting to call setIfNotEqual for the key 'test-key' in cache cacheName: ${result.errorCode()}: ${result.toString()}`
);
}
resp, err := client.SetIfNotEqual(ctx, &momento.SetIfNotEqualRequest{
CacheName: cacheName,
Key: momento.String("key"),
Value: momento.String("value"),
NotEqual: momento.String("current-value"),
})
if err != nil {
panic(err)
}
switch resp.(type) {
case *responses.SetIfNotEqualStored:
log.Printf("Successfully set key in cache\n")
}
match cache_client
.set_if_not_equal(cache_name, "key", "new-value", "cached-value")
.await?
{
SetIfNotEqualResponse::Stored => println!("Value stored"),
SetIfNotEqualResponse::NotStored => println!("Value not stored"),
}
SetIfPresentAndNotEqual
Do NOT use check-and-set (CAS) APIs such as SetIfPresentAndNotEqual
with scalar or non-CAS APIs such as Set
or Delete
.
Doing so will result in undefined consistency behaviors. Use SetIfAbsentOrEqual
instead with SetIfPresentAndNotEqual
.
Associates the provided value to a cache item with a given key if the key already exists in the cache and the value in the cache is not equal to the value supplied for notEqual
.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
key | String | Bytes | The key to be set. |
value | String | Bytes | The value to be stored. |
notEqual | String | Bytes | The value to compare with. |
ttlSeconds | Duration | Time to Live for the item in Cache. |
Method response object
- Stored
- NotStored
- Error
See response objects for specific information.
- JavaScript
- Go
- Rust
const result = await cacheClient.setIfPresentAndNotEqual(cacheName, 'test-key', 'test-field', 'value-to-check');
switch (result.type) {
case CacheSetIfPresentAndNotEqualResponse.Stored:
console.log("Field 'test-field' set in key 'test-key'");
break;
case CacheSetIfPresentAndNotEqualResponse.NotStored:
console.log(
`Key 'test-key' does not exist in cache ${cacheName} or equals 'value-to-check', so we did not set the field`
);
break;
case CacheSetIfPresentAndNotEqualResponse.Error:
throw new Error(
`An error occurred while attempting to call setIfPresentAndNotEqual for the key 'test-key' in cache cacheName: ${result.errorCode()}: ${result.toString()}`
);
}
resp, err := client.SetIfPresentAndNotEqual(ctx, &momento.SetIfPresentAndNotEqualRequest{
CacheName: cacheName,
Key: momento.String("key"),
Value: momento.String("value"),
NotEqual: momento.String("current-value"),
})
if err != nil {
panic(err)
}
switch resp.(type) {
case *responses.SetIfPresentAndNotEqualStored:
log.Printf("Successfully set key in cache\n")
}
match cache_client
.set_if_present_and_not_equal(cache_name, "key", "new-value", "cached-value")
.await?
{
SetIfPresentAndNotEqualResponse::Stored => println!("Value stored"),
SetIfPresentAndNotEqualResponse::NotStored => println!("Value not stored"),
}
SetIfAbsentOrEqual
Do NOT use check-and-set (CAS) APIs such as SetIfAbsentOrEqual
with scalar or non-CAS APIs such as Set
or Delete
.
Doing so will result in undefined consistency behaviors. Use SetIfPresentAndNotEqual
instead with SetIfAbsentOrEqual
.
Associates the provided value to a cache item with a given key if the key does not already exist in the cache or the value in the cache is equal to the value supplied for equal
.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
key | String | Bytes | The key to be set. |
value | String | Bytes | The value to be stored. |
equal | String | Bytes | The value to compare with. |
ttlSeconds | Duration | Time to Live for the item in Cache. |
Method response object
- Stored
- NotStored
- Error
See response objects for specific information.
- JavaScript
- Go
- Rust
const result = await cacheClient.setIfAbsentOrEqual(cacheName, 'test-key', 'test-field', 'value-to-check');
switch (result.type) {
case CacheSetIfAbsentOrEqualResponse.Stored:
console.log("Field 'test-field' set in key 'test-key'");
break;
case CacheSetIfAbsentOrEqualResponse.NotStored:
console.log(
`Key 'test-key' exists in cache ${cacheName} and is not equal to 'value-to-check', so we did not set the field`
);
break;
case CacheSetIfAbsentOrEqualResponse.Error:
throw new Error(
`An error occurred while attempting to call setIfAbsentOrEqual for the key 'test-key' in cache cacheName: ${result.errorCode()}: ${result.toString()}`
);
}
resp, err := client.SetIfAbsentOrEqual(ctx, &momento.SetIfAbsentOrEqualRequest{
CacheName: cacheName,
Key: momento.String("key"),
Value: momento.String("value"),
Equal: momento.String("current-value"),
})
if err != nil {
panic(err)
}
switch resp.(type) {
case *responses.SetIfAbsentOrEqualStored:
log.Printf("Successfully set key in cache\n")
}
match cache_client
.set_if_absent_or_equal(cache_name, "key", "new-value", "cached-value")
.await?
{
SetIfAbsentOrEqualResponse::Stored => println!("Value stored"),
SetIfAbsentOrEqualResponse::NotStored => println!("Value not stored"),
}
Time to Live APIs
These APIs apply across all cache types.
UpdateTtl
Overwrites the TTL of a cache item with the provided value in seconds.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
key | String | Bytes | The key under which the value's TTL is to be updated. |
ttl | Duration | Time to live that you want to update in cache in seconds. |
- Go
- Rust
resp, err := client.UpdateTtl(ctx, &momento.UpdateTtlRequest{
CacheName: cacheName,
Key: momento.String("key"),
Ttl: time.Duration(9999),
})
if err != nil {
panic(err)
}
switch resp.(type) {
case *responses.UpdateTtlSet:
log.Printf("Successfully updated TTL for key\n")
case *responses.UpdateTtlMiss:
log.Printf("Key does not exist in cache\n")
}
match cache_client
.update_ttl(cache_name, "key", Duration::from_secs(10))
.await?
{
UpdateTtlResponse::Set => println!("TTL updated"),
UpdateTtlResponse::Miss => println!("Cache miss, unable to find key to update TTL"),
};
IncreaseTtl
Increase the TTL seconds for a key to the provided value only if it would increase the TTL.
Examples
- If the TTL is 5 seconds and is increased to 6 seconds, the new TTL will be 6 seconds.
- If the TTL is 5 seconds and is increased to 3 seconds, the TTL will not be increased.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
key | String | Bytes | The key under which the value's TTL is to be increased. |
ttl | Duration | Time to live that you want to increase to. |
- Go
- Rust
resp, err := client.IncreaseTtl(ctx, &momento.IncreaseTtlRequest{
CacheName: cacheName,
Key: momento.String("key"),
Ttl: time.Duration(9999),
})
if err != nil {
panic(err)
}
switch resp.(type) {
case *responses.IncreaseTtlSet:
log.Printf("Successfully increased TTL for key\n")
case *responses.IncreaseTtlMiss:
log.Printf("Key does not exist in cache\n")
}
match cache_client
.increase_ttl(cache_name, "key", Duration::from_secs(5))
.await?
{
IncreaseTtlResponse::Set => println!("TTL updated"),
IncreaseTtlResponse::NotSet => println!("unable to increase TTL"),
IncreaseTtlResponse::Miss => println!("Cache miss, unable to find key to increase TTL"),
};
DecreaseTtl
Decrease the TTL seconds for a key to the provided value only if it would decrease the TTL.
Examples
- If the TTL is 5 seconds and is decreased to 3 seconds, the new TTL will be 3 seconds.
- If the TTL is 5 seconds and is decreased to 6 seconds, the TTL will not be decreased.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
key | String | Bytes | The key under which the value's TTL is to be decreased. |
ttl | Duration | Time to live that you want to decrease to. |
- Go
- Rust
resp, err := client.DecreaseTtl(ctx, &momento.DecreaseTtlRequest{
CacheName: cacheName,
Key: momento.String("key"),
Ttl: time.Duration(9999),
})
if err != nil {
panic(err)
}
switch resp.(type) {
case *responses.DecreaseTtlSet:
log.Printf("Successfully decreased TTL for key\n")
case *responses.DecreaseTtlMiss:
log.Printf("Key does not exist in cache\n")
}
match cache_client
.decrease_ttl(cache_name, "key", Duration::from_secs(3))
.await?
{
DecreaseTtlResponse::Set => println!("TTL updated"),
DecreaseTtlResponse::NotSet => println!("unable to decrease TTL"),
DecreaseTtlResponse::Miss => println!("Cache miss, unable to find key to decrease TTL"),
};
ItemGetTtl
For a given key, returns the duration of time remaining (Time To Live) before the item expires from the cache.
Name | Type | Description |
---|---|---|
cacheName | String | Name of the cache. |
key | String | Byte | Key whose item type should be returned. |
Method response object
- Cache hit
remainingTtl()
: Duration
- Cache miss
- Cache error
See response objects for specific information.
- Go
- Rust
resp, err := client.ItemGetTtl(ctx, &momento.ItemGetTtlRequest{
CacheName: cacheName,
Key: momento.String("key"),
})
if err != nil {
panic(err)
}
switch r := resp.(type) {
case *responses.ItemGetTtlHit:
log.Printf("TTL for key is %d\n", r.RemainingTtl().Milliseconds())
case *responses.ItemGetTtlMiss:
log.Printf("Key does not exist in cache\n")
}
let _remaining_ttl: Duration = cache_client
.item_get_ttl(cache_name, "key")
.await?
.try_into()
.expect("Expected an item ttl!");
Collection data types
Collections may contain different types of structures depending on your use case. Supported data types are:
- Dictionaries are used to store unordered field:value pairs.
- Lists are a collection of ordered elements, sorted in the sequence each element was inserted.
- Sets are an unordered collection of unique elements in string format.
- Sorted Sets are an ordered collection of unique elements. Each element contains a value:score pair.
For more in-depth information on usage, see collection data types.
Current status of API support in SDKs
For the current status of API support in various SDK languages, see the language support page.