Redis series (two) String, List type

A: String type

string is binary safe (picture video sequence storage, take out or can be used) up to 512M

get key (out)

            

set key(设key)

            

append key value (increase based on the original)

            

strlen key (length)

            

setnx key value (when there is not successfully set 1, unsuccessful 0)

            unsuccessful

             

            success

            

incr key (increment 1)

            (Atomicity, multithreading is not interrupted by other threads, i ++ is not atomically)

            

decr key (from minus 1)

            (Atomicity, multithreading is not interrupted by other threads)

            

incrby key 10(自增10)

            (Atomicity, multithreading is not interrupted by other threads)

            

decrby key 10 (from minus 10)

            (Atomicity, multithreading is not interrupted by other threads)

            

mset key1 value1 key2 value2 key3 value3 (once more into them)

            There is no time to create

             

 

            Sometimes cover

             

mget key1 key2 key3 (out once more)

            Sometimes out, there is no time to return nil (dd does not exist)

            

msetnx key1 value1 key2 value2 key3 value3 (execution s)

            Will not overwrite operation, all of the key must not exist when to perform successfully (1 successful, unsuccessful 0)

            bb exist, the operation is unsuccessful

            

 

            Do not exist, the success of the operation

            

getrange key start end (before and after substr are included)

            Substr similar functions, data return data, no data is returned '

             

setrange key start value (covering the key value start)

            Start from fourth place to cover aa

             

setex key expiration time value (set value and set an expiration time)

            Not to create a key, you have to cover

            

getset key value (set value at the same time get the old value)

            When covered acquire the old value, not the original, then return nil

            

Two: list type

            list data (key, [value1, value2, value3, value4]) is essentially a two-way linked list, poor operating performance index, the ordered set may be repeated

lpush key value1 value2 value3 value4 左边插入

            没有就创建key.相当于从0插入,以前的右移

           

rpush key value1 value2 value3 value4  右边插入

            没有就创建key.相当于append

            

lpop key    左边吐出

            返回删除的值

            

rpop key    右边吐出

            返回删除的值

            

rpoplpush key1 key2 (key1右边吐出值插入key2左边)

            只有这一个别的都没有(rpoprpush,lpoplpush,lpoprpush)

            

lrange key start stop(显示值,stop -1 显示所有的值)

            

lindex ket index(数组下标显示值)

            根据索引查找数据,不存在返回nil

             

llen(数组长度)

            

linsert key (before|after) value insertdata 

            在value之前或者之后插入insertdata,成功返回长度,不成功返回-1

            

lrem list 2 d (删除2个d,返回删除个数)

            返回删除个数

            

Guess you like

Origin www.cnblogs.com/wuxiaolong4/p/12129542.html
Recommended