Object built-in object

ObjectRedisSet

RedisDatabase client Set object. This object is the client containing the specified key. Only by calling its method will the database be operated.

used to operateRedisSet object, creation method:

1 2 3
var db = require("db"); var rdb = new db.openRedis("redis-server"); var set = rdb.getSet("test");

inheritance relationship

member function

add

Add one or more member elements to the collection key. Member elements that already exist in the collection will be ignored.

1
Integer RedisSet.add(Array members);

Call parameters:

  • members: Array, specifies the array of elements to be added

Return results:

  • Integer, the number of new elements added to the set, excluding ignored elements

Set multiple field-value (domain-value) pairs into the hash table at the same time. This command will overwrite the fields that already exist in the hash table.

1
Integer RedisSet.add(...members);

Call parameters:

  • members: ..., specifies the list of elements to be added

Return results:

  • Integer, the number of new elements added to the set, excluding ignored elements

remove

Remove one or more member elements from the collection

1
Integer RedisSet.remove(Array members);

Call parameters:

  • members: Array, specifies the array of elements to be removed

Return results:

  • Integer, the number of successfully removed elements, excluding ignored elements

Remove one or more member elements from the collection

1
Integer RedisSet.remove(...members);

Call parameters:

  • members: ..., specifies the list of elements to be removed

Return results:

  • Integer, the number of successfully removed elements, excluding ignored elements

len

Returns the number of elements in the collection

1
Integer RedisSet.len();

Return results:

  • Integer, returns the length of the collection

exists

Determine whether the member element is a member of the collection

1
Boolean RedisSet.exists(Buffer member);

Call parameters:

  • member:Buffer, specify the member to check

Return results:

  • Boolean, returns true if the member element is a member of the collection

members

Returns all members of the collection

1
NArray RedisSet.members();

Return results:

  • NArray, a list of all members in the set

pop

Removes and returns a random element from the collection

1
Buffer RedisSet.pop();

Return results:

  • Buffer, the random element that was removed. When the set is empty, returns null

randMember

Get a random element from the collection

1
Value RedisSet.randMember();

Return results:

  • Value, returns an element; if the collection is empty, returns null

Get random elements from a collection

1
Value RedisSet.randMember(Integer count);

Call parameters:

  • count: Integer, specifies the number of elements to be returned. Positive number, returns an array containing count elements; negative number, returns an array, the elements in the array may be repeated multiple times, and the length of the array is the absolute value of count

Return results:

  • Value, returns a list; if the collection is empty, returns an empty list

toString

Returns the string representation of the object. Generally, "[Native Object]" is returned. The object can be re-implemented according to its own characteristics.

1
String RedisSet.toString();

Return results:

  • String, returns the string representation of the object

toJSON

Returns a JSON format representation of the object, generally returning a collection of readable properties defined by the object.

1
Value RedisSet.toJSON(String key = "");

Call parameters:

  • key: String, not used

Return results:

  • Value, returns a value containing JSON serializable