client.redis.set
Set a RedisOS key with optional TTL.
Signature
class Client {
redis: {
set(key: string, value: string, opts?: { ttl?: number }): Promise<void>
}
}
Parameters
| Name | Type | Required | Notes |
|---|---|---|---|
| string | yes | Redis key name |
| string | yes | Value to store |
| number | no | Time-to-live in seconds |
Examples
await bf.redis.set('session:abc123', 'user_data', { ttl: 3600 })
Throws
| Error | Condition |
|---|---|
| API request failed |
| Network issue |
Pitfalls
- String-only values — use JSON.stringify for complex objects
- TTL overwrites — setting a new TTL on an existing key replaces the previous TTL
See also
{auto-injected}
Tested against
{auto-injected}