Skip to main content

Class: CacheService

Implements

  • ICacheService

Constructors

constructor

new CacheService(__namedParameters)

Parameters

NameType
__namedParametersObject

Defined in

packages/medusa/src/services/cache.ts:10

Properties

redis_

Protected Readonly redis_: Redis

Defined in

packages/medusa/src/services/cache.ts:8

Methods

get

get<T>(cacheKey): Promise<null | T>

Retrieve a cached value belonging to the given key.

Type parameters

Name
T

Parameters

NameType
cacheKeystring

Returns

Promise<null | T>

Implementation of

ICacheService.get

Defined in

packages/medusa/src/services/cache.ts:40


invalidate

invalidate(key): Promise<void>

Invalidate cache for a specific key. a key can be either a specific key or more global such as "ps:*".

Parameters

NameType
keystring

Returns

Promise<void>

Implementation of

ICacheService.invalidate

Defined in

packages/medusa/src/services/cache.ts:56


set

set(key, data, ttl?): Promise<void>

Set a key/value pair to the cache. It is also possible to manage the ttl through environment variable using CACHE_TTL. If the ttl is 0 it will act like the value should not be cached at all.

Parameters

NameTypeDefault value
keystringundefined
dataRecord<string, unknown>undefined
ttlnumberDEFAULT_CACHE_TIME

Returns

Promise<void>

Implementation of

ICacheService.set

Defined in

packages/medusa/src/services/cache.ts:22