Skip to main content

Accessing cache

Runnables can access an attached cache (such as Redis) using the cache namespace of the Runnable API. Atmo will configure the cache, and will bind it to the Runnable at runtime.

note

Atmo provides a default in-memory cache when there is no external cache is configured. Refer to the Connections docs to learn how to connect an external cache to Atmo.

In Rust these methods are available under the cache module:

# Use the "cache" module
use suborbital::cache;

# Invoke the "Get" method
cache::get()

The following namespace methods are available:

Set

Set a given key's value in the cache. The provided TTL is in seconds.

STATUS: STABLE
pub fn set(key: &str, val: Vec<u8>, ttl: i32)

Get

Get the provided key from the cache.

STATUS: STABLE
pub fn get(key: &str) -> Result<Vec<u8>, RunErr>

Additional cache operations are coming soon.