Home / node / Commands / type-aliases / SetOptions @valkey/valkey-glide
@valkey/valkey-glide / Commands / SetOptions
Type Alias: SetOptions
SetOptions = {
conditionalSet?:"onlyIfExists"|"onlyIfDoesNotExist"; } | {comparisonValue:GlideString;conditionalSet:"onlyIfEqual"; } &object
Type declaration
expiry?
optionalexpiry:"keepExisting"| {count:number;type:TimeUnit; }
Example
import {TimeUnit} from "@valkey/valkey-glide";
await client.set(key, JSON.stringify(key), {
expiry: {
type: TimeUnit.Seconds,
count: 60,
},
});
If not set, no expiry time will be set for the value.
keepExisting - Retain the time to live associated with the key.
Equivalent to KEEPTTL in the Valkey API.
returnOldValue?
optionalreturnOldValue:boolean
Return the old string stored at key, or nil if key did not exist. An error
is returned and SET aborted if the value stored at key is not a string.
Equivalent to GET in the Valkey API.