redis practice

redis-server start the service

enter redis redis-cli

 

redis common key operation keys:

exists key --- check whether there are key

del key1 key2 --- delete the specified key 

type key --- Check the key Type

rename oldkey newkey --- change the key name

dbsize --- returns the current number of key database

expire key seconds --- specify an expiration time for the key

ttl key --- return key remaining expiration time

select db-index --- select database

move key db-index --- key to move from the current database to the specified database

flushdb --- delete all the current key database

flushall --- delete all database key

 

string type of operation:

set key value --- key value corresponding to the set

get key --- to get key value

mset key1 value key2 value --- a plurality of setting values ​​of the key

mget key1 key2 --- key once to obtain a plurality of values

incr key --- +1 on key values ​​of (value must only be int) and returns the new value

--- DECR key on key value -1 (value must only be int) and returns the new value

incrbyfloat key int --- with incr, plus a specified value

decrbyfloat key int --- with decr, minus the specified value

--- the append key value to the specified value key string value is added

substr key start end --- returns a string value of the key is taken over (not modify the original value)

 

list the type of operation:

lpush key string --- list corresponding to the head of the key add a string

rpop key - remove elements from the end of the list, and returns the element

llen key --- return the length of the list, key exists returns 0

lrange key start end --- return elements within the specified range, the start index from 0

rpush key string --- above, add in the tail

lpop key - as above, remove elements from the head

ltrin key start end - interception list, to retain the element within the designated section

 

Guess you like

Origin www.cnblogs.com/bnsdmmL/p/11068003.html