Home > @imqueue/rpc > RedisCache

RedisCache class

Class RedisCache. Implements a cache engine on top of Redis.

Signature:

export declare class RedisCache implements ICache 

Implements: ICache

Properties

Property

Modifiers

Type

Description

name

string

options

IRedisCacheOptions

ready

boolean

Methods

Method

Modifiers

Description

del(key)

Removes the value stored in the cache under the given key.

destroy()

static

Safely destroys the Redis connection.

get(key)

Returns the value stored in the cache under a given key.

init(options)

Initializes the cache instance. The underlying Redis connection is shared between all instances; concurrent initializations share a single connection attempt.

purge(keyMask)

Purges all keys from the cache matching a given wildcard mask.

set(key, value, ttl, nx)

Stores the given value in the cache under the given key. If TTL is specified, the cached value will expire after the given number of milliseconds. If the NX argument is set to true, the key:value pair is created only if it does not exist yet. The given value can be any JSON-compatible object and will be serialized automatically.