SDK
SDK Javascript v5.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

srandmember #

Returns one or more members of a set of unique values, at random.
If count is provided and is positive, the returned values are unique. If count is negative, a set member can be returned multiple times.

[Redis documentation]


srandmember(key, [options], callback) #

ArgumentsTypeDescription
keystringKey identifier
optionsJSON ObjectOptional parameters
callbackfunctionCallback

Options #

OptionTypeDescriptionDefault
countintNumber of members to return. If set with a positive value, the returned values are unique. If count is negative, a set member can be returned multiple times1
queuablebooleanMake this request queuable or nottrue

Callback Response #

Returns an array of members of a set of unique values.

Usage #

// Using callbacks (NodeJS or Web Browser)
kuzzle.memoryStorage.srandmember('key', function (err, members) {
  // callback called once the action has completed
});
// Using promises (NodeJS only)
kuzzle.memoryStorage.srandmemberPromise('key')
  .then(members => {
    // resolved once the action has completed
  });

Callback response:

["member1", "member2", "..."]