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

This adapter instance's name, 'RedisCache'. Used as the registry key and as a segment of every cache key.

options

IRedisCacheOptions

The effective options after merging user input over DEFAULT_REDIS_CACHE_OPTIONS.

ready

boolean

True once RedisCache.init() has completed successfully.

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.

Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.