tencent cloud

All product documents
Tencent Cloud Observability Platform
Client.set
Last updated: 2025-03-11 20:05:00
Client.set
Last updated: 2025-03-11 20:05:00
The set method is used to set the value of the specified key.
set(key: string, value: string, expiration?: number): string

Parameters

Parameter
Type
Description
key
string
Key name
value
string
Value.
expiration
number
Optional; indicates expiration time in seconds. If left blank, no expiration time will be set. -1 indicates keepttl.

Return

Type
Description
string
On success, "OK" is returned.

Samples

import redis from "pts/redis";

let client = new redis.Client("redis://:<password>@<host>:6379/0");

export default function main() {
let setResp = client.set("key", "hello, world", 0);
console.log(redis set ${setResp}); // OK
let getResp = client.get("key");
console.log(redis get ${getResp}); // hello, world
}

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support