Preface
Company hand-Tour using Redis as a database, although doing testing work, but still feel it necessary to understand some of the relevant concepts of Redis and basic operations. Before doing the page trip test involves memcache,Tokyo tyrant but using tools developed by others to understand almost zero. Learn the following commands to complete the basic query insert operation.
One, basic understanding:
redis key-value memcache flush save on the hard drive.
1 can be seen as memcache
2 support for network, journaled, Key-value-type databases
3 supports regular numeric, string,Lists,sets,Sorted Sets,Hashes.
4 Get help information:
Second, the basic operation:
Set key value |
Set Key and its value |
Get key |
Querying data |
Del key |
Delete a key value |
exists key |
Verify that the key value exists, ' means not present, 1 stands for existence |
setnx key |
key already exists return 0 no return 1 |
Setex Key |
expiry date Ten seconds: Setex name Jake |
SetRange |
settings specify key :setrange Key 8 163.com will key eighth character and subsequent 7 163.co |
mset key1 key2 ... |
set multiple at once Span style= "font-family: ' Microsoft yahei ', SimSun, Verdana, Arial, Helvetica, sans-serif;line-height:21px;font-size : 10.5pt; " >key |
mget key1 Key2 ... .. |
Get the value of multiple keys at once |
msetnx key1 Key2 ... .. |
Set multiple key-value pairs at once and determine if they already exist |
Getset Key |
Sets the value of key and returns the old value of key |
GetRange key N1 N2 |
Gets the substring of the specified range specified by key The last character is-1, descending forward in turn |
INCR key |
Value plus 1 |
Incrby Key Intvalue |
Plus the specified value |
Decr |
Value minus 1 |
Decrby Key Intvalue |
Subtract the specified value |
Append key string |
Append string at end |
Strlen Key |
Gets the length of the specified string |
Third, the hash table operation, especially for storing objects:
1. hset key field value
Summary:set the string value of a hash field
2. hsetnx key field value
Summary:set the value of a hash field, only if the field does not exist
3. hmset key field value [field value ...]
Summary:set multiple hash fields to multiple values
4. hget key Field
Summary:get the value of a hash field
5. hmget key field [field ...]
Summary:get the values of all the given hash fields
6. Hincrby key field increment
Summary:increment the integer value of a hash field by the given number
7. hexists key Field
Summary:determine If a hash field exists
8. Hlen Key
Summary:get the number of fields in a hash
9, Hdel key key field [field ...]
Summary:delete one or more hash fields
10, Hkeys
Summary:get all the fields in a hash
11, Hvals
Summary:get all the values in a hash
12, Hgetall
Summary:get all, and values in a hash
This article is from a "sword Siege" blog, please make sure to keep this source http://weijiancheng.blog.51cto.com/10190955/1676851
Basic knowledge of Redis