BlueForge Docs

client.redis.expire

Set a TTL on a RedisOS key.

Signature

class Client {
  redis: {
    expire(key: string, ttl: number): Promise<boolean>
  }
}

Parameters

NameTypeRequiredNotes
key
stringyesRedis key name
ttl
numberyesTime-to-live in seconds

Returns

true
if the TTL was set,
false
if the key doesn't exist.

Examples

await bf.redis.expire('temp:data', 86400) // expire in 24 hours

Throws

ErrorCondition
ApiError
API request failed
NetworkError
Network issue

Pitfalls

  • Already-expired keys — setting TTL on a key that has already expired returns
    false
  • TTL precision — TTL is specified in seconds, not milliseconds

See also

{auto-injected}

Tested against

{auto-injected}