Redis04 - Redis common grammar

Redis grammar

1.string

  • select db select the database (0-20)
  • a setting data set kv
  • set k1 v nx nx can be inserted only when new data
  • set k2 v xx xx can only be updated when the data is updated
  • mset k1 v1 k2 v2 can be set a plurality of values
  • get k return a v, did not return nil
  • mget k1 k2 k3 get more v
  • getrange k start end acquires an index from start to end, the double closing section
  • setrange k start value update interval range, we can start from the index start updating value data
  • del key to delete a data kv
  • keys pattern with a regular query key
  • flushdb empty db
  • help @string query string-sensitive help
  • append kv k is added to the data of this data v
  • type k see what type of value
  • object encoding k v View data types
  • incr k1 plus the integer data type a
  • incrby k1 v v plus the integer data type
  • decr k1 minus the integer data type a
  • decrby k1 v v Save the integer data type
  • incrbyfloat k1 v integer data type to add a float
  • Data is not long enough when coding is embstr, after changes to raw format
  • strlen k1 view of the length of v
  • redis-cli --raw be entered, will identification code (such as Automatic Identification GBK)
  • getset k1 v update the new value and return the old value
  • bitpos key bit [start] [end] view of bytes from the start to end, the first bit to appear
  • bitcount key [start] [end] View start to end when the number 1 appears
  • bitop and andkey k1 k2 k1 k2 performing bitwise AND operation
  • bitop or orkey k1 k2 bitwise OR operation

2.list

  • lpush, lpop, rpush, rpop and stack as
  • lrange 0 -1 all elements View
  • lindex key index to see the index value of the position
  • lrem key count value count the number of removed value
  • linsert key after afval value after the key value is inserted
  • linsert key before befval value inserted in front of the key value
  • blpop blocking value (wait for re-extracted value)
  • ltrim key [start] [end] pruning, trimming queue

3.hash

  • hset key filed value set a key field value of
  • hget key field to obtain a key field value of
  • hmset key field value field value of the plurality of field values
  • hmget key field fied to obtain the value of the plurality of field
  • hkeys key to see all the key
  • View all hvals key field
  • hincrby key field num num value increase

4.set

  • sadd key v1 v2 v3 ... insert v1, v2, v3 ...
  • smember key lists all of the value
  • srem v1 v2 delete v1, v2 ...
  • sinter k1 k2 and returns the intersection of
  • sinterstore dest k1 k2 intersection results stored dest
  • seek and set sunion k1 k2 return
  • sunionstore dest k1 k2 set and stored dest
  • sdiff k1 k2 set and returns differencing
  • sdiffstore dest k1 k2 differencing sets stored dest
  • srandmember k1 returns a random member
  • srandmember k1 num random element returns num, num is a positive number, to remove a heavy result set, if it is negative, then the result set of a weight not taken

5.zset

  • zadd k score mem score data is inserted to increase the weight mem

  • zrange k 0 -1 remove all values

  • zrangebyscore k low high data extracted from low to high range

  • zrange k start end removed from the start to the end of data between

  • zscore kv returns a data value

  • zscore kv returns a ranked data

  • zrange k 0 -1 withscores carry fraction removed

  • zincrby k incrscore v increases a score value

  • zunionstore k keynum k1 k2 .. [aggregate max] and the plurality of key set [maximum]

Guess you like

Origin www.cnblogs.com/littlepage/p/11515553.html