Object built-in object

Object RedisList

Redis database client List object, this object is the client that contains the specified key, and the database can only be operated by calling its method

To manipulate the List object of Redis , create method:

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

Inheritance

Member function

push

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

1
Integer RedisList.push(Array values);

Call parameters:

  • values : Array, specify the data to be inserted

Return result:

  • Integer , the length of the list after insertion

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

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

Call parameters:

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

Return result:

  • Integer , the length of the list after insertion

pop

Remove and return the head element of the list key

1
Buffer RedisList.pop();

Return result:

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

rpush

Insert one or more values ​​at the end of the list (far right)

1
Integer RedisList.rpush(Array values);

Call parameters:

  • values : Array, specify the data to be inserted

Return result:

  • Integer , the length of the list after insertion

Insert one or more values ​​at the end of the list (far right)

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

Call parameters:

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

Return result:

  • Integer , the length of the list after insertion

rpop

Remove and return the tail (rightmost) element of the list key

1
Buffer RedisList.rpop();

Return result:

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

set

Set the value of the element whose index is 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 index is index

1
Buffer RedisList.get(Integer index);

Call parameters:

  • index : Integer, specify the subscript to be queried

Return result:

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

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 find when inserting
  • value : Buffer , specify the data to be inserted

Return result:

  • 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 find when inserting
  • value : Buffer , specify the data to be inserted

Return result:

  • Integer , the length of the list after insertion

remove

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

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

Call parameters:

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

Return result:

  • Integer , the number of removed elements

trim

Trim a list, that is, let the list retain only the elements in the specified interval, and the elements not in the specified interval will be deleted

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

Call parameters:

  • start : Integer, specify the starting index of trimming, 0 means the first element, -1 means the last element
  • stop : Integer, specify the ending index of trimming, 0 means the first element, -1 means the last element

len

Return the length of the list

1
Integer RedisList.len();

Return result:

  • 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, specify the starting index of the query, 0 means the first element, -1 means the last element
  • stop : Integer, specify the end index of the query, 0 means the first element, -1 means the last element

Return result:

  • NArray , an array containing elements in the specified range

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

Call parameters:

  • key : String, unused

Return result:

  • Value , returns a value containing JSON serializable