Redis Command Parsing

Source: Internet
Author: User

Redis command collection

Redis command summary connection operation related commands


Quit: disconnect)

Auth: Simple Password Authentication


Persistence


Save: synchronize and save data to the disk.

Bgsave: asynchronously saves data to the disk.

Lastsave: returns the Unix timestamp from which data is successfully saved to the disk.

Shundown: synchronize and save the data to the disk, and then close the service.


Remote Service Control


Info: provides server information and statistics.

Monitor: Real-time dump of received requests

Slaveof: changes the replication policy settings

Config: configure the redis server at runtime


Command for value operation


Exists (key): Check whether a key exists.

Del (key): deletes a key.

Type (key): Type of the returned value

Keys (pattern): returns all keys that meet the given pattern.

Randomkey: Random return of a key space

Keyrename (oldname, newname): Rename the key

Dbsize: returns the number of keys in the current database.

Expire: Set the activity time of a key (s)

TTL: obtains the activity time of a key.

Select (INDEX): query by index

Move (key, dbindex): Move the key in the current database to the dbindex Database

Flushdb: delete all keys in the selected database.

Flushall: delete all keys in all databases


String operation command


Set (key, value): assign value to the string named key in the database

Get (key): returns the value of a string named key in the database.

GetSet (Key, value): Assign the last value to the string named key.

Mget (key1, key2 ,..., Key N): returns the value of multiple strings in the database.

Setnx (Key, value): Add a string named key and Value

Setex (Key, time, value): Add a string to the database and set the expiration time.

Mset (key N, value n): Batch set values of multiple strings

Msetnx (key N, value n): If all strings named key I do not exist

Incr (key): Add 1 to a string named key

Incrby (Key, integer): Add integer to the string named key

Decr (key): String minus 1 operation whose name is key

Decrby (Key, integer): reduce integer in the string with the name of key

Append (Key, value): append the value of string with the name of key

Substr (Key, start, end): returns the substring of the value of the string named key.


List Operation Command


Rpush (Key, value): adds an element with the value at the end of the list named key.

Lpush (Key, value): adds an element with value to the list header named key.

Llen (key): returns the length of the list named key.

Lrange (Key, start, end): returns the elements between start and end in the list named key.

Ltrim (Key, start, end): truncates a list named key.

Lindex (Key, index): returns the index position element of the list named key.

Lset (Key, index, value): assigns a value to the element at the index position in the list named key.

Lrem (Key, Count, value): deletes the element whose value is the value in the list of Count keys.

Lpop (key): returns and deletes the first element from the list named key.

Rpop (key): returns and deletes the end element of the list named key.

Blpop (key1, key2 ,... Key N, timeout): The Block version of The lpop command.

Brpop (key1, key2 ,... Key N, timeout): rpop block version.

Rpoplpush (srckey, dstkey): returns and deletes the end element of the list named srckey, and adds this element to the header of the list named dstkey.


Set operation commands


Sadd (Key, member): add the element member to the set named key.

Srem (Key, member): deletes the element member from the set named key.

Spop (key): Randomly returns and deletes an element in a set named key.

Smove (srckey, dstkey, member): Move to the set Element

Scard (key): returns the base number of a set named key.

Sismember (Key, member): whether Member is an element of a set named key

Sinter (key1, key2 ,... Key N): calculates the intersection.

Sinterstore (dstkey, (KEYS): calculates and saves the intersection to the dstkey set.

Sunion (key1, (KEYS): returns the Union set.

Sunionstore (dstkey, (KEYS): calculates the Union and saves the Union to the collection of dstkey.

Sdiff (key1, (KEYS): returns the difference set.

Sdiffstore (dstkey, (KEYS): calculates the difference set and saves the difference set to the set of dstkey.

Smembers (key): returns all elements of a set named key.

Srandmember (key): Random return of an element of the Set named key


Hash Operation Command


Hset (Key, field, value): Add an element field to the hash named key.

Hget (Key, field): returns the value of the field in the hash with the key name.

Hmet (Key, (fields): returns the value corresponding to field I in the hash with the key name.

Hmset (Key, (fields): adds an element field to the hash named key.

Hincrby (Key, field, integer): adds an integer to the field value in the hash named key.

Hexists (Key, field): indicates whether the hash with the key as the field exists.

Hdel (Key, field): Delete the field in the hash key named key.

Hlen (key): returns the number of elements in the hash key.

Hkeys (key): returns all keys in the hash key

Hvals (key): return the value corresponding to all keys in the hash with the key name.

Hgetall (key): returns all the keys (fields) and their corresponding values in the hash key.



Redis import scripts

Insert hundreds of thousands of data into the key names to provide the name when the player logs on to the game for the first time. The solution is to save all namescontent in suijiming.txt text.
Script

#! /Bin/bash

While read line

Do

Echo $ line

Redis-cli lpush names $ line

Done <suijiming.txt


Blocked word

Import the shielded words to redis, and create a key,dirty_names. then, import the shielded words to the database in the pingbizi.txt text.

#! /Bin/bash

While read line

Do

Echo $ line

Redis-cli sadd dirty_names $ line

Done <pingbizi.txt


This article from the "Flying Tianying ----- blood kill group" blog, please be sure to keep this source http://749806593.blog.51cto.com/6662384/1539325

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.