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.
WHERE IT SITS
INTERFACE
struct RedisStorestructA 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 = "") -> RedisStorefnA store over client, prefixing every key with prefix.
fn RedisStore::client(self : RedisStore) -> @moonredis.ClientfnThe 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) -> StringfnThe key actually written for key.
impl @cache.Store for RedisStore with fn get( self : RedisStore, key : String) -> Bytes? raiseitem
impl @cache.Store for RedisStore with fn set( self : RedisStore, key : String, value : Bytes, ttl_ms : Int64) -> Unit raiseitem
impl @cache.Store for RedisStore with fn del( self : RedisStore, key : String) -> Unit raiseitem
extend RedisStore with @cache.Store::item
async fn RedisStore::add( self : RedisStore, key : String, delta : Int64) -> Int64 raise @cache.RefuseditemAdd 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.RefuseditemHow 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.RefuseditemDrop 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.