Thanks to visit codestin.com
Credit goes to docs.nocobase.com

Cache

Basic Methods

Refer to the node-cache-manager documentation.

  • get()
  • set()
  • del()
  • reset()
  • wrap()
  • mset()
  • mget()
  • mdel()
  • keys()
  • ttl()

Other Methods

wrapWithCondition()

Similar to wrap(), but allows you to conditionally decide whether to use the cache.

async wrapWithCondition<T>(
  key: string,
  fn: () => T | Promise<T>,
  options?: {
    // External parameter to control whether to use the cached result
    useCache?: boolean;
    // Decide whether to cache based on the data result
    isCacheable?: (val: unknown) => boolean | Promise<boolean>;
    ttl?: Milliseconds;
  },
): Promise<T> {

setValueInObject()

When the cached content is an object, change the value of a specific key.

async setValueInObject(key: string, objectKey: string, value: unknown)

getValueInObject()

When the cached content is an object, get the value of a specific key.

async getValueInObject(key: string, objectKey: string)

delValueInObject()

When the cached content is an object, delete a specific key.

async delValueInObject(key: string, objectKey: string)