ObjectRedisHash
RedisDatabase client Hash object. This object is the client containing the specified key. Only by calling its method will the database be operated.
used to operateRedisHash object, creation method:
1
2
3var db = require("db");
var rdb = new db.openRedis("redis-server");
var hash = rdb.getHash("test");
inheritance relationship
member function
set
Set the value of the field field in the hash table to value. If the field field already exists in the hash table, the old value will be overwritten.
1
2RedisHash.set(Buffer field,
Buffer value);
Call parameters:
setNX
Set the value of the field field in the hash table to value if and only if the field field does not exist. If the domain field already exists, this operation is invalid
1
2RedisHash.setNX(Buffer field,
Buffer value);
Call parameters:
mset
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.
1RedisHash.mset(Object kvs);
Call parameters:
- kvs: Object, specifies the field/value object to be set
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.
1RedisHash.mset(...kvs);
Call parameters:
- kvs: ..., specify the field/value list to be set
get
Returns the value of the given field in the hash table
1Buffer RedisHash.get(Buffer field);
Call parameters:
- field:Buffer, specify the field to be queried
Return results:
- Buffer, the value of a given field, when the given field does not exist or the given key does not exist, returns null
mget
Returns the value of one or more given fields in a hash table
1NArray RedisHash.mget(Array fields);
Call parameters:
- fields: Array, specifies the domain array to be queried
Return results:
- NArray, a list containing all values of a given domain
Returns the value of one or more given fields in a hash table
1NArray RedisHash.mget(...fields);
Call parameters:
- fields: ..., specify the domain list to be queried
Return results:
- NArray, a list containing all values of a given domain
incr
Increment the value stored in the field
1
2Long RedisHash.incr(Buffer field,
Long num = 1);
Call parameters:
- field:Buffer, specify the domain to be modified
- num: Long, specifies the value to be added
Return results:
- Long, after adding num, the value of the domain
getAll
Returns all fields and values in the hash table
1NArray RedisHash.getAll();
Return results:
- NArray, returns a list containing all fields in the hash table
keys
Returns all fields in the hash table
1NArray RedisHash.keys();
Return results:
- NArray, in the return value, immediately following each domain name (field name) is the value of the field (value), so the length of the return value is twice the size of the hash table
len
Returns the number of fields in the hash table
1Integer RedisHash.len();
Return results:
- Integer, returns the number of fields in the hash table
exists
Check whether the given domain field exists in the hash table
1Boolean RedisHash.exists(Buffer field);
Call parameters:
- field:Buffer, specify the field to be queried
Return results:
- Boolean, if the hash table contains the given field, return true, if the hash table does not contain the given field, or the key does not exist, return false
del
Delete one or more specified fields in the hash table. Non-existing fields will be ignored.
1Integer RedisHash.del(Array fields);
Call parameters:
- fields: Array, specifies the domain array to be deleted
Return results:
- Integer, the number of deleted domains
Delete one or more specified fields in the hash table. Non-existing fields will be ignored.
1Integer RedisHash.del(...fields);
Call parameters:
- fields: ..., specifies the list of domains to delete
Return results:
- Integer, the number of deleted domains
toString
Returns the string representation of the object. Generally, "[Native Object]" is returned. The object can be re-implemented according to its own characteristics.
1String RedisHash.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.
1Value RedisHash.toJSON(String key = "");
Call parameters:
- key: String, not used
Return results:
- Value, returns a value containing JSON serializable