Object built-in object

ObjectRedisList

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

used to operateRedisList object, creation method:

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

inheritance relationship

member function

push

Insert one or more values ​​into the head of the list

1
Integer RedisList.push(Array values);

Call parameters:

  • values: Array, specify the data to be inserted

Return results:

  • Integer, the length of the list after insertion

Insert one or more values ​​into the head of the list

1
Integer RedisList.push(...values);

Call parameters:

  • values: ..., specify the data to be inserted

Return results:

  • Integer, the length of the list after insertion

pop

Remove and return the head element of the list key

1
Buffer RedisList.pop();

Return results:

  • Buffer, the head element of the list, returns null if the list is empty

rpush

Insert one or more values ​​into the end (rightmost) of the list

1
Integer RedisList.rpush(Array values);

Call parameters:

  • values: Array, specify the data to be inserted

Return results:

  • Integer, the length of the list after insertion

Insert one or more values ​​into the end (rightmost) of the list

1
Integer RedisList.rpush(...values);

Call parameters:

  • values: ..., specify the data to be inserted

Return results:

  • Integer, the length of the list after insertion

rpop

Removes and returns the tail (rightmost) element of the list key

1
Buffer RedisList.rpop();

Return results:

  • Buffer, the head element of the list, returns null if the list is empty

set

Set the value of the element with index in the list to value

1 2
RedisList.set(Integer index, Buffer value);

Call parameters:

  • index: Integer, specify the subscript to be modified
  • value:Buffer, specify the data to be modified

get

Returns the element in the list whose subscript is index

1
Buffer RedisList.get(Integer index);

Call parameters:

  • index: Integer, specify the subscript to be queried

Return results:

  • Buffer, the element whose subscript is index in the list

insertBefore

Insert the value value into the list before the value pivot

1 2
Integer RedisList.insertBefore(Buffer pivot, Buffer value);

Call parameters:

  • pivot:Buffer, specify the data to be searched for when inserting
  • value:Buffer, specify the data to be inserted

Return results:

  • Integer, the length of the list after insertion

insertAfter

Insert the value value into the list after the value pivot

1 2
Integer RedisList.insertAfter(Buffer pivot, Buffer value);

Call parameters:

  • pivot:Buffer, specify the data to be searched for when inserting
  • value:Buffer, specify the data to be inserted

Return results:

  • Integer, the length of the list after insertion

remove

According to the value of parameter count, remove the elements in the list that are equal to parameter value

1 2
Integer RedisList.remove(Integer count, Buffer value);

Call parameters:

  • count: Integer, specifies the number of elements to delete
  • value:Buffer, specify the value to be deleted

Return results:

  • Integer, the number of elements removed

trim

Trim a list, that is, let the list only retain elements within the specified range, and elements that are not within the specified range will be deleted.

1 2
RedisList.trim(Integer start, Integer stop);

Call parameters:

  • start: Integer, specifies the starting index of pruning, 0 represents the first element, -1 represents the last element
  • stop: Integer, specifies the end index of pruning, 0 represents the first element, -1 represents the last element

len

Returns the length of the list

1
Integer RedisList.len();

Return results:

  • Integer, returns the length of the list

range

Returns the elements in the specified interval in the list. The interval is specified by offsets start and stop, and contains the elements of start and stop.

1 2
NArray RedisList.range(Integer start, Integer stop);

Call parameters:

  • start: Integer, specifies the starting subscript of the query, 0 represents the first element, -1 represents the last element
  • stop: Integer, specifies the end index of the query, 0 represents the first element, -1 represents the last element

Return results:

  • NArray, an array containing elements within the specified range

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 RedisList.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 RedisList.toJSON(String key = "");

Call parameters:

  • key: String, not used

Return results:

  • Value, returns a value containing JSON serializable