tencent cloud

Tencent Cloud Observability Platform

Client.sRandMember

PDF
Focus Mode
Font Size
Last updated: 2025-03-11 20:05:04
The sRandMember method is used to randomly return an element in the set.
sRandMember(key: string): string

Parameters

Parameter
Type
Description
key
string
Key name.

Return

Type
Description
string
On success, an element is randomly returned.

Samples

import redis from "pts/redis";

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

export default function main() {
let sAddResp = client.sAdd("set", "hello", "world");
console.log(redis sAdd ${sAddResp}); // 2
let sRandMemberResp = client.sRandMember("set");
console.log(redis sRandMember ${sRandMemberResp}); // world
}


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback