Object built-in object

Object RedisHash

Redis The database client Hash 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 Hash object, creation method:

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

Inheritance

#lineWidth: 1.5 #font: Helvetica,sans-Serif #fontSize: 10 #leading: 1.6 #.this: fill=lightgray #.class: fill=white [<class>object|toString();toJSON()] [<this>RedisHash|set();setNX();mset();get();mget();incr();getAll();keys();len();exists();del()] [object] <:- [RedisHash] object toString() toJSON() RedisHash set() setNX() mset() get() mget() incr() getAll() keys() len() exists() del()

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 2
RedisHash.set(Buffer field, Buffer value);

Call parameters:

  • field: Buffer, Specify the field to be modified
  • value: Buffer, Specify the data to be modified

setNX

Set the value of the field in the hash table to value, if and only if the field does not exist. If the field already exists, this operation is invalid

1 2
RedisHash.setNX(Buffer field, Buffer value);

Call parameters:

  • field: Buffer, Specify the field to be modified
  • value: Buffer, Specify the data to be modified

mset

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

1
RedisHash.mset(Object kvs);

Call parameters:

  • kvs: Object, specify the field/value object to be set

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

1
RedisHash.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

1
Buffer RedisHash.get(Buffer field);

Call parameters:

  • field: Buffer, Specify the field to be queried

Return result:

  • Buffer, The value of the given field, when the given field does not exist or the given key does not exist, return null

mget

Returns the value of one or more given fields in the hash table

1
NArray RedisHash.mget(Array fields);

Call parameters:

  • fields: Array, specify the domain array to be queried

Return result:

  • NArray, A list containing all the values ​​of a given domain

Returns the value of one or more given fields in the hash table

1
NArray RedisHash.mget(...fields);

Call parameters:

  • fields: ..., specify the list of domains to be queried

Return result:

  • NArray, A list containing all the values ​​of a given domain

incr

Add the increment to the value stored in the field

1 2
Long RedisHash.incr(Buffer field, Long num = 1);

Call parameters:

  • field: Buffer, Specify the domain to be modified
  • num: Long, specify the value to be added

Return result:

  • Long, After adding num, the value of the domain

getAll

Return all fields and values ​​in the hash table

1
NArray RedisHash.getAll();

Return result:

  • NArray, Returns a list of all fields in the hash table

keys

Return all fields in the hash table

1
NArray RedisHash.keys();

Return result:

  • NArray, In the return value, immediately after each field name is the value of the field, 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

1
Integer RedisHash.len();

Return result:

  • Integer, Returns the number of fields in the hash table

exists

Check whether the given field exists in the hash table

1
Boolean RedisHash.exists(Buffer field);

Call parameters:

  • field: Buffer, Specify the field to be queried

Return result:

  • Boolean, If the hash table contains the given domain, return true, if the hash table does not contain the given domain, or the key does not exist, return false

del

Delete one or more specified domains in the hash table, domains that do not exist will be ignored

1
Integer RedisHash.del(Array fields);

Call parameters:

  • fields: Array, specify the field array to be deleted

Return result:

  • Integer, The number of deleted domains

Delete one or more specified domains in the hash table, domains that do not exist will be ignored

1
Integer RedisHash.del(...fields);

Call parameters:

  • fields: ..., specify the list of domains to be deleted

Return result:

  • Integer, The number of deleted domains

toString

Returns the string representation of the object, generally returns "[Native Object]", the object can be re-implemented according to its own characteristics

1
String RedisHash.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

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

Call parameters:

  • key: String, unused

Return result:

  • Value, Returns a value containing JSON serializable