redis data type of list

1、lpush

LPUSH (name, values)
 # additive element name in the list corresponding to each new elements are added to the list of the leftmost 
# as: 
    # conn.lpush ( 'OO', 11,22,33) 
    # save the order : 33,22,11 
# extended: 
    # RPUSH (name, values) indicate operating from right to left

2、lpushx

lpushx (name, value)
 # additive element in the list corresponding to the name, only name already exists, add the value to the left of the list 
# more: 
    # rpushx (name, value) represents the operation from right to left

3, linsert

linsert (name, WHERE, REFVALUE, value))
 # insert a new value before a certain value of the name list corresponding to or after 
# parameters: 
    # name, Redis the name 
    # WHERE, the BEFORE or an AFTER 
    # REFVALUE, benchmark value, i.e., : in its data before and after insertion 
    # value, data to be inserted

4、lpop

lpop (name)
 # Get the name list on the left corresponding to the first element in the list and be removed, the return value is the first element 
# more: 
    # RPOP (name) represents the operation from right to left

5, lrem

conn.lrem (name, value, NUM)
 # removed name list corresponding to the value specified in 
# parameters: 
    # name, the name Redis 
    # value, the value to be deleted 
    # NUM, NUM = 0, delete the list of all specified value; 
           # NUM = 2, front to back, deleting 2; 
           # NUM = -2, forward, delete 2 from

6, lset

conn.lset (name, index, value)
 # of a name corresponding to an index position in the re-assignment list 
# : Parameters 
    # name, the name Redis 
    # index, the index position list 
    # value value, to be set

7.blpop

BLPOP (Keys, timeout)
 # plurality of lists are arranged, from left to right to pop the corresponding list element 
# parameters: 
    # Keys, set the name of redis 
    # timeout, timeout, after a list of all the elements of the element acquired End time data (seconds), blocking the waiting list, 0 blocked forever 
# more: 
    # r.brpop (Keys, timeout), from right to left to get data

8、lrange

Lrange (name, start, End)
 # obtain data corresponding to the name list slice 
# parameters: 
    # name, the name Redis 
    # start position start, index 
    # End, the end position of the index

9, lrange stack prone to burst phenomenon, treatment options: imitate hscan_iter

def list_iter(key,count=100):
    index = 0
    while True:
        data_list = conn.lrange(key, index, index+count-1)
        if not data_list:
            return
        index += count

        for item in data_list:
            yield item


for item in list_iter('k1',count=3):
    print(item)

10 len

LLEN (name)
 # number of the name list corresponding to the elements

11、lindex

the lindex (name, index)
 # acquired name list element in the list corresponding to the index

12, rpoplpush

rpoplpush (the src, DST)
 # removed from a list, the rightmost element, while adding it to the left of another list 
# parameters: 
    # the src, to name list of supported data 
    # DST, a data list name to be added

13、brpoplpush

brpoplpush (the src, DST, timeout)
 # from the right side removes an element of a list and add it to the left of another list 
# parameters: 
    # the src, and taken to remove the element corresponding to the list name 
    # DST, to insert the element corresponding to the list name 
    # timeout, when the corresponding list src no data block waiting timeout that data (in seconds), indicates block forever 0

14, LTrim

LTRIM (name, start, End)
 # removed no value between the start-end of the index corresponding to the name list 
# parameters: 
    # name, the name Redis 
    # start position start, index 
    # End, the end position of the index

 

Guess you like

Origin www.cnblogs.com/wt7018/p/11571019.html