Redis common operation command

  
operation related command connection quit: close connection (connection) auth: simple password authentication persistent save: save data to disk bgsave: save data asynchronously to disk lastsave: return last successful save data to Disk Unix timestamp shundown: Save data to disk synchronously, then turn off service remote service control info: Provide server information and statistics monitor: Real-time dump received request slaveof: Change replication policy settings config: Configure Redis at runtime The server's command to value operation exists(key): Confirm whether a key has del(key): delete a keytype(key): return type: keys(pattern): return all keyrandomkeys that satisfy the given pattern: randomly return keyspace A keyrename (oldname, newname): rename keydbsize: return the number of keys in the current database expire: set a key activity time (s) ttl: get a key activity time select (index): query by index move ( Key, dbindex): move when The key in the database to the dbindex database flushdb: delete all keyflushall in the current selection database: delete all the commands in the database to the string operation set (key, value): give the value of the string named key in the database valueget (key ): Returns the valuegetset(key, value) of the string named key in the database: assign the last valuemget (key1, key2, …, key N) to the string named key: return the valuesetnx of multiple strings in the library ( Key, value): add string, the name is key, the value is valuesetex(key, time, value): add string to the library, set the expiration time timemset(key N, value N): batch set the value of multiple strings msetnx (key N, value N): If all strings with the name key i do not have incr(key): the string whose name is key is incremented by 1 operation incrby(key, integer): the string whose name is key is incremented by integerdecr(key): The string whose name is key minus 1 operates decrby(key, integer): the string whose name is key decreases integerappend(key, value): the value of the string whose name is key is appended to valuesubstr(key, start, end): the name is key String value Substring-to-List operation command rpush(key, value): Add an element with value of value lpush(key, value) at the end of the list whose name is key: add an element with value as value in the list header named key Llen (key): Returns the length of the list named key. lrange(key, start, end): Returns the element between the start and the end of the list named key. ltrim(key, start, end): intercepts the name as key. Listlindex(key, index): Returns the element lset(key, index, value) of the index position in the list named key: assigns the element of the index position in the list named key to lrem(key, count, value): delete count The key of the key list is the value of the element lpop (key): return and delete the first element rpop (key) in the list named key: return and delete the tail element blpop (key1, key2, in the list named key) … key N, timeout): The block version of the lpop command. Brpop(key1, key2, … key N, timeout): The block version of rpop. Rpoplpush(srckey, dstkey): Returns and deletes the tail element of the list named srckey, and adds the element to the head of the list named dstkey. The command to the Set operation is the addd(key, member): to the name key Add the elements membersque(key, member) in the set: delete the member memberspop(key) in the set whose name is key: randomly return and delete an element in the set named key (srckey, dstkey, member): move to the collection element Scard(key) : Returns the cardinality of the set named key. sismember(key, member) :member is the element of the set named key sinter(key1, key2,…key N) : intersection sinterstore(dstkey, (keys )) : Find the intersection and save the intersection to the dskey collection sunion(key1, (keys)) : Find the union sunionstore(dstkey, (keys)) : Find the union and save the union to the dstkey collection sdiff(key1, (keys): Find the difference set sdiffstore(dstkey, (keys)) : Find the difference set and save the difference set to dstkey's set smembers(key) : Return all elements of the set named key to srandmember(key) : Randomly return An element of the set named key is a command to the Hash operation hset(k Ey, field, value): Add the element fieldhget(key, field) to the hash named key: return the valuehmget(key, (fields)) corresponding to the field in the name of the key: return the field in the hash named key i corresponding valuehmset (key, (fields)): add the element field hincrby (key, field, integer) to the hash named name key: increase the value of the field in the hash named key to integerhexists (key, field): name For the hash of the key, is there a field with the key field: hdel(key, field): delete the field with the name key as the field of the field hlen(key): return the number of elements in the hash named hkeys(key) : Returns all the keys in the hash named key. hvals(key): Returns the valuehgetall(key) corresponding to all keys in the hash named key: returns all the keys (field) and their corresponding values ​​in the hash named key.
Copyright © Windows knowledge All Rights Reserved