Class: CacheService
Implements
ICacheService
Constructors
constructor
• new CacheService(__namedParameters
)
Parameters
Name | Type |
---|---|
__namedParameters | Object |
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
Name | Type |
---|---|
cacheKey | string |
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
Name | Type |
---|---|
key | string |
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
Name | Type | Default value |
---|---|---|
key | string | undefined |
data | Record <string , unknown > | undefined |
ttl | number | DEFAULT_CACHE_TIME |
Returns
Promise
<void
>
Implementation of
ICacheService.set