# ICache.set() method · @imqueue/rpc

Source: https://imqueue.org/api/rpc/latest/rpc.icache.set/
Published: 2026-08-04
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/rpc 3.5.3 — generated reference, not hand-written

Stores the given value in the cache under the given key.

**Signature:**

```typescript
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](https://imqueue.org/api/rpc/latest/rpc.cache/) decorator always passes it.

