Http://www.cnblogs.com/chenping-987123/archive/2012/01/29/2331079.html 
Redis is an open source, advanced storage of key-value pairs. It is often used as a service-side data structure, and its key data types can be strings, HASHS, lists, sets (unordered sets) and sorted sets (ordered sets). 
If we want to use Redis under Windows as a learning use, you can go to https://github.com/dmajkic/redis/downloads download the latest Windows Redis, the latest version is currently 2.4.5
 
Now that you can unzip it, there are 2 folders, corresponding to 32-bit Windows, 64-bit Windows.
 
The author's computer is 32-bit Win7 Professional Edition, so open the 32 folder, you can look at some config, exe file, double-click Redis-server.exe run. You can see some information:
 
Port number: 6379; The redis.conf configuration file is used, Redis version number: 2.4.5, and the number of connections to the client.
 
At this point, you can double-click Redis-cli.exe to run a client, you can see Redis after running 127.0.0.1:6379
 
You can now use a command to show the functionality of the Redis. Redis's orders are as follows:
 
Connection control
 
QUIT Close Connection
 
AUTH (when enabled only) Simple password verification
 
Suitable for all types of commands
 
EXISTS key to determine whether a key exists; there is a return of 1; otherwise, return 0;
 
DEL key Deletes a key, or a series of Key;del Key1 Key2 Key3 Key4
 
Type key returns the data type of a key element (none: Not present, string: Character, List,set,zset,hash)
 
Keys pattern returns a matching key list (keys foo*: Find the keys at the beginning of Foo)
 
Randomkey randomly obtains an already existing key and returns an empty string if the current database is empty
 
RENAME oldname newname Change the name of the key, and the new key will be overwritten if it exists
 
Renamenx oldname newname Change the name of the key, if the name exists, the change fails
 
Dbsize returns the total number of key keys in the current database
 
EXPIRE Sets the expiration time (in seconds) of a key, (EXPIRE Bruce 1000: Set Bruce this key1000 seconds after the system is automatically deleted) Note: If the value has not expired, the values are changed, then the value will be cleared.
 
How long does the TTL find a key to expire, and returns the second time
 
Select Index Choose Database
 
Move key Dbindex moves the specified key from the current database to the target database Dbindex. Successful return of 1, otherwise return 0 (the source database does not exist key or the target database already has the same name key);
 
Flushdb empty all keys in the current database
 
Flushall clears all keys in all databases
 
Commands for handling strings
 
Set key value sets a string value for a key. Set KeyName datalength data (set Bruce Paitoubing: Save Key is Burce, string length is 10 of a string paitoubing to the database), the data maximum can not exceed 1G.
 
Get key gets the value of a key. If the key does not exist, the string "nil" is returned and an error is returned if the value of the key is not a string type.
 
Getset key value can be understood as the value of the obtained key and set this value, more convenient operation (set Bruce Paitoubing, this time need to modify Bruce to 1234567890 and get the previous data paitoubing , Getset Bruce 10 1234567890)
 
Mget key1 Key2 ... keyn a one-time return value of multiple keys
 
The difference between Setnx key value Setnx and set is that set can create and update key value, and setnx if key does not exist, create key and value data
 
Mset key1 value1 key2 value2 ... keyn valuen set multiple keys and values one at a time under atomic operation
 
Msetnx key1 value1 key2 value2 ... keyn valuen set multiple keys and values at once under atomic operation (if the target key does not exist, it fails if more than one key already exists)
 
INCR key Self-add value
 
Incrby key integer To specify a value by itself
 
DECR key self-subtraction value
 
Decrby key integer To specify numeric values by self reduction
 
Handling the lists command
 
Rpush key value adds an element from the end of the List (if the sequence does not exist, it is created first, an error is returned if a key of the same name already exists, not a sequence)
 
Lpush key value adds an element from the List header
 
Llen Key returns the length of a List
 
Lrange key start to return the elements of the sequence from a custom range (Lrange testlist 0 2; return sequence testlist top 0 1 2 elements)
 
LTRIM key start to trim data outside a range (LTRIM testlist 0 2; Keep 0 1 2 elements, delete the rest)
 
Lindex key index Returns the sequence value of a position (lindex testlist 0; Returns the element where the sequence testlist position is 0)
 
LSET Key index value updates the value of a location element
 
Lrem Key Count value deletes a certain number (count) of elements that match value from the head (count positive) or tail (count negative numbers) of the List, returning the number of deleted elements.
 
Lpop key pops up the first element of the List
 
Rpop key pops up the last element of the List
 
Rpoplpush Srckey Dstkey pops up the last element in the _SRCKEY_ and presses it into the _DSTKEY_ header and returns "nil" if the key does not exist or the sequence is empty.
 
Commands for handling collections (sets) (indexed unordered sequences)
 
Sadd key member increases the element to the sets sequence, adds success 1 if the element (Membe) does not exist, or fails 0; (Sadd testlist 3 \ One)
 
Srem key member Deletes an element of the sets sequence, fails 0 if the element does not exist, or succeeds 1 (Srem testlist 3 \ n One)
 
Spop key randomly pops a member from the collection
 
Smove Srckey Dstkey member moves an element of a sets sequence to another sets sequence (Smove testlist test 3\n Two, from the sequence testlist move element two to test, testlist No two element exists)
 
SCard key counts the number of elements in a sets sequence
 
Sismember key member to see if the specified members exist in the collection
 
Sinter key1 Key2 ... Keyn returns Key1, Key2, ..., intersection in Keyn
 
Sinterstore dstkey key1 key2 ... Keyn will Key1, Key2, ..., Keyn in the intersection deposit Dstkey
 
Sunion key1 Key2 ... Keyn returns Key1, Key2, ..., Keyn of the collection
 
Sunionstore Dstkey key1 Key2 Keyn will Key1, Key2, ..., Keyn and set deposit in Dstkey
 
Sdiff key1 Key2 ... keyn according to Key2, Keyn seek the difference set of Key1. Official Example:
 
Key1 = X,a,b,c
 
Key2 = C
 
Key3 = A,d
 
Sdiff Key1,key2,key3 => x,b
 
Sdiffstore Dstkey key1 Key2 Keyn According to Key2, ... Keyn the difference set and deposit Key1
 
Smembers key returns all elements of a sequence
 
Srandmember key randomly returns elements of a sequence
 
Commands for processing ordered collections (sorted sets) (Zsets)
 
Zadd key score member to add specified members to an ordered set and update score if the target exists (score, sort)
 
Zrem key member deletes specified members from an ordered collection
 
Zincrby Key Increment member adds _increment_ if a member is present, or it sets a score as _increment_
 
Zrange Key start end returns a member of the specified range after ascending sort
 
Zrevrange Key start end returns a member of the specified range after descending sort
 
Zrangebyscore key min Max returns all member <= key that conforms to score >= min and score Zcard Max returns an ordered set of elements Zscore key element returns the score value of the specified member Zremrangebyscore Key min Max deletes all members that meet score >= min and score <= max conditions
 
Sort (List, set, Sorted set)
 
The SORT key by pattern LIMIT The start end get pattern asc| DESC ALPHA to sort the collection or list in the specified mode
 
SORT MyList
 
Default ascending ASC
 
SORT MyList DESC
 
SORT mylist LIMIT 0 10
 
Starting with serial number 0, take 10
 
SORT mylist LIMIT 0 ALPHA DESC
 
Sort by first character
 
SORT MyList by weight_*
 
SORT mylist by weight_* get object_*
 
SORT mylist by weight_* get object_* Get #
 
SORT mylist by weight_* STORE Resultkey
 
The returned results are stored in the Resultkey sequence (List)
 
Persistent control
 
Save synchronize data to disk
 
Bgsave asynchronously saves data to disk
 
Lastsave returns the Unix timestamp that was last successfully saved to disk
 
SHUTDOWN sync to the server and shut down the Redis server (save+quit)
 
Bgrewriteaof the log file when it is too long
 
Remote CONTROL command
 
Info provides information and statistics about the server
 
Monitor to output all incoming requests in real time
 
slaveof Modify Replication Options
 
 
Commands are all uppercase, in fact lowercase is also possible.
 
The simplest example:
Set OK OK
 
Get OK
 
Specific orders you can try one at a while.