1, install [[email protected] ~]# tar zxvf redis-3.0.2.tar.gz[[email protected] ~]# mv Redis-3.0.2/usr/local/redis[[email prote CTED] ~]# Cd/usr/local/redis[[email protected] Redis] #make &&make installover
Make error
ZMALLOC.H:50:31: Error: jemalloc/jemalloc.h: no file or directory
Using make MALLOC=LIBC && make install
#官方网站提示这样启动服务
Src/redis-server
#但是出现了上面的问题后, please start the Redis service in the following way
Nohup src/redis-server redis.conf &
Turn off Redis
REDIS-CLI shutdown
2.
Key related instructions
Exists key key exists to return 1, no return 0 exists.
Del key1 Keyn deletes the specified key, returning the number of successful deletions.
Type key to view the data type of key
Randomkey The current library randomly returns a key
Rename Oldkey newkey Rename a key, if Newkey is the name that exists, then Newkey will be deleted.
Renamenx Ibid, if there will be renaming failed, return 0.
Expire key seconds for key specifies the expiration time unit is seconds 0
TTL key returns the remaining expiration time of key, 1 = Not set-2 indicates expired
Select Db-index Choose a database equal to use datebases, the default connection is 0, the default is 16.
Move key Db-index moves key to the specified database, returns 1 for success, and 0 indicates failure.
3.
Redis's value
String hash list set sorted set 5 kinds
3.1 String type
Set key setting key or update key
Setnx key creates a key and returns 0 if it already exists.
Get key gets the value of key
Getset key value Gets the value of key and then updates the value of key
Mget key1 Keyn Bulk Acquisition
Mset key1 value1 key2 value2 Batch setup, if there is an error, no action will be done.
Msetnx key1 value1 Key2 value2 Ibid. however, if there is an existing key, no action will be made.
Ince Key does a +1 operation on key, and if it is not an int type, an error will be made, and if key does not exist, 1 will be returned.
Decy key to key do-1 operation, other ibid.
Incrby key integer to key plus the specified value, if key does not exist will create
Decrby key integer to the key minus the specified value, the other ibid, can be negative, to achieve incrby effect, the same.
3.2
Hash type
Hset key field value is set and created if it does not exist, for example: Hset ID xiaoming 19912213 | Hset Age Xiaoming 17
Hget key field gets the key value of field for example: Hget ID xiaoming
Hmget key field1 Field2 bulk Gain, for example: Hmget ID xiaoming daming
Hmset key Field1 value1 ... Batch setup For example: Hmset age xiaoming 19 Daming
Hincrby key field integer Adds an integer to the key, and a successful return value can be negative.
Hexists key field detects if field and key exist, returns 1 otherwise returns 0
Hdel key field deletes the specified key when field does not exist without key.
Hlen Key returns the number of field for the specified key
Hkeys Key returns all field of key
Hvals key returns all value of key
Hgetall Key returns all filed and value of key
3.3
List Type original address http://www.cnblogs.com/stephen-liu74/archive/2012/02/14/2351859.html
Command prototypes |
Complexity of Time |
Command description |
return value |
LP ush key value [value ...] |
o (1) |
All values given in the header insert parameter of the list value associated with the specified key. If the key does not exist, the command creates an empty list associated with the key before inserting it, and then inserts the data from the list's head. If the value of the key is not a linked list type, the command returns a related error message. |
The number of elements in the linked list after being inserted. |
LP Ushx key value |
O (1) |
only if the key specified in the parameter exists, the command will be given the value in the header of its associated list value, otherwise no action will occur. |
The number of elements in the linked list after the insert. |
LR ANGE key start stop |
|
Returns a list of elements within a specified range. |
LP op key |
< Span style= "Color:rgb (0,0,255);" >o (1) |
returns and pops the first element, the head element, in the linked list of the specified key association. If the key does not exist, returns nil. |
The element of the linked list head. |
LL EN&NBSP key |
o (1) |
Returns the number of elements in the linked list associated with the specified key, or 0 if the key does not exist. If the type of value associated with the key is not a linked list, the associated error message is returned. |
The number of elements in the linked list. |
LR em key count value |
|
Returns the number of elements that were deleted. |
LS et key index value |
|
|
LI Ndex key index |
O (N) |
|
Returns the element that is requested, or nil if index is out of range. |
LT rim key start stop |
|
LI Nsert key before| After pivot value |
o (N) |
|
After successfully inserting the number of elements in the linked list, if no pivot is found, return 1 if key does not exist, return 0. |
RP USH key Value [value ...] |
o (1) |
All values given in the trailing insert parameter of the list value associated with the specified key. If the key does not exist, the command creates an empty list associated with the key before inserting, and then inserts the data from the end of the list. If the value of the key is not a linked list type, the command returns a related error message. |
The number of elements in the linked list after being inserted. |
RP Ushx key value |
O (1) |
only if the key specified in the parameter exists, the command will be given the value in the end of its associated list value, otherwise no action will occur. |
The number of elements in the linked list after being inserted. |
RP op key |
< Span style= "Color:rgb (0,0,255);" >o (1) |
returns and pops the last element, the trailing element, in the linked list associated with the specified key. If the key does not exist, returns nil. |
The element at the tail of the list. |
rpoplpush Source destination |
O (1) |
atomically pops an element from the tail of the linked list associated with the source key, and then inserts the popup element into the head of the linked list associated with the destination key. If the source key does not exist, the command returns nil and does not do any other operations at the same time. If source and destination are the same key, then the equivalent of atomicity moves the trailing element in its associated list to the head of the linked list. |
Returns the popup and inserted elements. |
The first day over.
This article is from the "Gentle" blog, please be sure to keep this source http://dangyibo.blog.51cto.com/4219248/1665192
The first day of Redis learning