get

Function get 

Source
pub fn get<T: Extract>(
    key: impl AsRef<[u8]>,
) -> Result<Option<T>, CacheGetError<T::Error>>
Expand description

Get a value from the cache.

Examples:


Bytes:


let value: Option<Vec<u8>> = cache::get("my_key")?;

Json:

use momento_functions_host::encoding::Json;

#[derive(serde::Deserialize)]
struct MyStruct {
  message: String
}

let value: Option<Json<MyStruct>> = cache::get("my_key")?;