First, download
Official website address:
https://redis.io/
5.0.7 version Download:
http://download.redis.io/releases/redis-5.0.7.tar.gz
Linux command line Downloads:
wget -c http://download.redis.io/releases/redis-5.0.7.tar.gz
Second, the installation
After downloading the command line, run:
tar -xvf redis-5.0.7.tar.gz
Enter redis-5.0.7 folder:
cd redis-5.0.7/
Compile:
make
installation:
make install
Installation directory /usr/local/bin
.
Third, run
In unpacked directory /root/cece/redis-5.0.7
execute:
/usr/local/bin/redis-server redis.conf
Screenshot below:
Fourth, the test
Links database:
/usr/local/bin/redis-cli
Set the key:
set test 123456
Get the key:
get test
Screenshot below:
Five, redis basic operations
1, Connection (connection)
- AUTH password - authentication password
- ECHO
- PING
- QUIT - requests the server closes the current connection to the client
- SELECT index - Switch to the specified database, the database index number specified by the index numeric value to 0 as the starting index.
2, string (Strings)
- Get key-name - get the value stored in a given keys
- Set key-name - get the value stored in a given keys
- Del key-name - value delete files stored on a given keys (for all types)
list (Lists) - RPush list-key item - pushing the given value list right
- LRange list-key start stop - get a list of all the values in a given range
- LIndex list-key index - Get a list of individual elements in a given position on the
- LPop list-key - pop a value from the left end of the list, and returns the value
3, set (Sets)
- sadd set-key item - the given item to the collection element (element returns 0 already exists in the collection, add 1 represents successful)
- smembers set-key - returns a collection of all the elements
- sismember set-key item - checking whether the given element is present in the collection item
- srem set-key item - If the item is present in the collection, the element is removed (removal returns the number of elements)
4, hash (Hashes)
- hset hash-key sub-key value - is provided in the hash key for a given
- hget hash-key sub-key - Gets the value of the specified key in hash
- hgetall hash-key - get all the hash key-value pairs
- hdel hash-key sub-key - to remove a given hash key (the presence of a return, there is no return 0)
5, ordered set (Sorted Sets)
- zadd zset-key score member - with one member of a given value is added to the ordered set
- zrange zset-key start stop [withscores] - The position of the element is located in the ordered set, the ordered set inside acquired from the plurality of elements
- zrangebyscore zset-key start stop [withscores] - Gets the ordered set of all the elements within a given value range
- zrem zset-key member - Removes the given members in the ordered set (1 returned present, there is no return 0)
- zrevrank zset-key member - return an ordered collection of members of the member's ranking member in descending order by score
- zrevrange zset-key start stop [withscores] - Returns to the ordered set of members within a given range of positions, members by score in descending order
6, other commands (Other Commands)
- sort source-key [BY pattern] [Limit offset count] [Get pattern [Get pattern ...]] [Asc | Desc] [Alpha] [Store dest-key] - according to the given options, the list input, set or results ordered set be sorted, stored, or sorted to return
7, publish / subscribe (publish / subscribe)
- subscribe channel [channel ...] - given subscribed channel (s)
- unsubscribe [channel [channel ...]] - unsubscribe given channel, if the channel is not given, all channels will unsubscribe
- publish channel message - a message sent to a given channel
- psubscribe pattern [pattern ...] - subscribe to match a given pattern of channels
- punsubscribe [pattern [pattern ...]] - all unsubscribe given pattern matching pattern, if not given mode, all modes unsubscribe
8, the expiration time (expiring keys)
- persist key-name - remove the key expiration time
- ttl key-name - View from the given key, how many seconds expired
- expire key-name seconds - let the specified key expire after a given number of seconds
- expireat key-name timestamp - given set the expiration time stamp given Unix
- pttl key-name - View from the given key expiration how many milliseconds (version> = 2.6)
- pexpire key-name milliseconds - let designated key expires after a given number of milliseconds (version> = 2.6)
- pexpireat key-name timestamp-milliseconds - given the expiration time to the millisecond accuracy of the given Unix timestamp (version> = 2.6)
9, the operation bitmap (Bitmap)
- BITOP AND destkey key [key ...], one or more logical key request and save the results to destkey.
- BITOP OR destkey key [key ...], one or more logical or key request, to save the results destkey.
- BITOP XOR destkey key [key ...], one or more logical XOR key request and save the results to destkey.
- BITOP NOT destkey key, key requirements for a given logical negation, save the results to destkey.
Six, redis command Detailed
Resource Links (offline Quick):
https://download.csdn.net/download/Martin_chen2/12185924