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. Atmo provides a default in-memory cache if no external cache is connected.

note

Documentation for connecting an external cache to Atmo can be found here.

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.

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

Get​

Get the provided key from the cache.

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

Additional cache operations are coming soon.