ICache.set() method

Stores the given value in the cache under the given key.

Signature:

set(key: string, value: any, ttl?: number): Promise<boolean>;

Parameters

Parameter

Type

Description

key

string

key to store the value under

value

any

value to store

ttl

number

(Optional) time-to-live in milliseconds

Returns:

Promise<boolean>

a truthy value when the write happened, falsy when it did not

Remarks

Test the result for truthiness rather than comparing against true — the built-in Redis adapter resolves to the string 'OK' or to null, never to a boolean.

The framework additionally passes a fourth argument, an nx flag meaning "only create the key if it does not already exist". Adapters that cannot honour it should say so, because the cache decorator always passes it.

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