moonzero · control plane v0.15.0 · 49 packages · 4 targets · Apache-2.0 docs / data / redis GitHub

03 / DATA

redis

The same Store contract the memory store implements, over a redis client and a key prefix, so a cache moves from one process to a fleet by changing the value passed in — plus the counter and expiry operations a cache does not use.

struct RedisStore

structA Store whose entries live in redis, under a key prefix. Every key is prefix + key, so one redis serves several caches without them colliding.

fn RedisStore::new( client : @moonredis.Client, prefix~ : String = "") -> RedisStore

fnA store over client, prefixing every key with prefix.

fn RedisStore::client(self : RedisStore) -> @moonredis.Client

fnThe redis client this store writes through, for a caller that needs a command the cache does not use.

fn RedisStore::key_of(self : RedisStore, key : String) -> String

fnThe key actually written for key.

impl @cache.Store for RedisStore with fn get( self : RedisStore, key : String) -> Bytes? raise

item

impl @cache.Store for RedisStore with fn set( self : RedisStore, key : String, value : Bytes, ttl_ms : Int64) -> Unit raise

item

impl @cache.Store for RedisStore with fn del( self : RedisStore, key : String) -> Unit raise

item

extend RedisStore with @cache.Store::

item

async fn RedisStore::add( self : RedisStore, key : String, delta : Int64) -> Int64 raise @cache.Refused

itemAdd delta to the counter under key and return the new value. A counter is not a cached value: it lives in redis so every replica increments one number.

async fn RedisStore::ttl_ms( self : RedisStore, key : String) -> Int64 raise @cache.Refused

itemHow long key has left, in milliseconds; -2 when it does not exist and -1 when it has no expiry.

async fn RedisStore::re_expire( self : RedisStore, ttl_ms : Int64) -> Int32 raise @cache.Refused

itemDrop every TTL under the prefix and let them expire with ttl_ms instead — what a deploy does after changing how long a cache entry should live.