Object RedisSet
Redis The database client Set object, this object is the client that contains the specified key, and the database can only be operated when its method is called
To operate Redis The Set object, creation method:
1
2
3var db = require("db");
var rdb = new db.openRedis("redis-server");
var set = rdb.getSet("test");
Inheritance
Member function
add
Add one or more member elements to the set key, and the member elements that already exist in the set will be ignored
1Integer RedisSet.add(Array members);
Call parameters:
- members: Array, specify the array of elements to be added
Return result:
- Integer, The number of new elements added to the set, excluding ignored elements
Set multiple field-value (domain-value) pairs to the hash table at the same time, this command will overwrite the existing fields in the hash table
1Integer RedisSet.add(...members);
Call parameters:
- members: ..., specify the list of elements to be added
Return result:
- Integer, The number of new elements added to the set, excluding ignored elements
remove
Remove one or more member elements from the collection
1Integer RedisSet.remove(Array members);
Call parameters:
- members: Array, specify the array of elements to be removed
Return result:
- Integer, The number of elements successfully removed, excluding ignored elements
Remove one or more member elements from the collection
1Integer RedisSet.remove(...members);
Call parameters:
- members: ..., specify the list of elements to be removed
Return result:
- Integer, The number of elements successfully removed, excluding ignored elements
len
Returns the number of elements in the collection
1Integer RedisSet.len();
Return result:
- Integer, Returns the length of the collection
exists
Determine whether the member element is a member of the collection
1Boolean RedisSet.exists(Buffer member);
Call parameters:
- member: Buffer, Specify the member to be checked
Return result:
- Boolean, If the member element is a member of the collection, return true
members
Return all members in the collection
1NArray RedisSet.members();
Return result:
- NArray, A list of all members in the collection
pop
Remove and return a random element in the set
1Buffer RedisSet.pop();
Return result:
- Buffer, The random element that was removed. When the set is empty, return null
randMember
Get a random element from the set
1Value RedisSet.randMember();
Return result:
- Value, Return an element; if the collection is empty, return null
Get some random elements from the set
1Value RedisSet.randMember(Integer count);
Call parameters:
- count: Integer, specifies the number of elements returned. A positive number, returns an array containing count elements; a negative number, returns an array, the elements in the array may repeat multiple times, and the length of the array is the absolute value of count
Return result:
- Value, Return a list; if the collection is empty, return an empty list
toString
Returns the string representation of the object, generally returns "[Native Object]", the object can be re-implemented according to its own characteristics
1String RedisSet.toString();
Return result:
- String, Returns the string representation of the object
toJSON
Returns the JSON format representation of the object, generally returns a collection of readable attributes defined by the object
1Value RedisSet.toJSON(String key = "");
Call parameters:
- key: String, unused
Return result:
- Value, Returns a value containing JSON serializable