set(key: string, value: string, expiration?: number): string
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. |
Type | Description |
string | On success, "OK" is returned. |
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
}
); // OKlet getResp = client.get("key");console.log(redis
get
$
{
getResp
}
); // hello, world}