Skip to content

Class: RedisCache ​

Defined in: packages/redis/src/index.ts:32

A CacheStore in Redis or Valkey, shared by every process that uses the same server and prefix.

clear() bumps a generation counter instead of deleting keys: entries of an older generation are no longer read, and expire on their own TTL. It is one INCR, on a cluster too.

Implements ​

  • CacheStore

Constructors ​

Constructor ​

ts
new RedisCache(options): RedisCache;

Defined in: packages/redis/src/index.ts:42

Parameters ​

ParameterType
optionsRedisCacheOptions

Returns ​

RedisCache

Methods ​

clear() ​

ts
clear(): Promise<void>;

Defined in: packages/redis/src/index.ts:80

Returns ​

Promise<void>

Implementation of ​

CacheStore.clear


get() ​

ts
get(key): Promise<unknown>;

Defined in: packages/redis/src/index.ts:57

Parameters ​

ParameterType
keystring

Returns ​

Promise<unknown>

Implementation of ​

CacheStore.get


set() ​

ts
set(
   key, 
   value, 
   ttlMs
): Promise<void>;

Defined in: packages/redis/src/index.ts:72

Parameters ​

ParameterType
keystring
valueunknown
ttlMsnumber

Returns ​

Promise<void>

Implementation of ​

CacheStore.set

Released under the MIT License. Inspired by spatie/laravel-permission.