linux environment redis redis basic operation environment setup and

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.7execute:

/usr/local/bin/redis-server redis.conf

Screenshot below:
redis start screenshot

Fourth, the test

Links database:

/usr/local/bin/redis-cli

Set the key:

set test 123456

Get the key:

get test

Screenshot below:
Test redis database

Five, redis basic operations

1, Connection (connection)

  1. AUTH password - authentication password
  2. ECHO
  3. PING
  4. QUIT - requests the server closes the current connection to the client
  5. 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)

  1. Get key-name - get the value stored in a given keys
  2. Set key-name - get the value stored in a given keys
  3. Del key-name - value delete files stored on a given keys (for all types)
    list (Lists)
  4. RPush list-key item - pushing the given value list right
  5. LRange list-key start stop - get a list of all the values ​​in a given range
  6. LIndex list-key index - Get a list of individual elements in a given position on the
  7. LPop list-key - pop a value from the left end of the list, and returns the value

3, set (Sets)

  1. sadd set-key item - the given item to the collection element (element returns 0 already exists in the collection, add 1 represents successful)
  2. smembers set-key - returns a collection of all the elements
  3. sismember set-key item - checking whether the given element is present in the collection item
  4. 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)

  1. hset hash-key sub-key value - is provided in the hash key for a given
  2. hget hash-key sub-key - Gets the value of the specified key in hash
  3. hgetall hash-key - get all the hash key-value pairs
  4. 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)

  1. zadd zset-key score member - with one member of a given value is added to the ordered set
  2. 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
  3. zrangebyscore zset-key start stop [withscores] - Gets the ordered set of all the elements within a given value range
  4. zrem zset-key member - Removes the given members in the ordered set (1 returned present, there is no return 0)
  5. zrevrank zset-key member - return an ordered collection of members of the member's ranking member in descending order by score
  6. 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)

  1. 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)

  1. subscribe channel [channel ...] - given subscribed channel (s)
  2. unsubscribe [channel [channel ...]] - unsubscribe given channel, if the channel is not given, all channels will unsubscribe
  3. publish channel message - a message sent to a given channel
  4. psubscribe pattern [pattern ...] - subscribe to match a given pattern of channels
  5. punsubscribe [pattern [pattern ...]] - all unsubscribe given pattern matching pattern, if not given mode, all modes unsubscribe

8, the expiration time (expiring keys)

  1. persist key-name - remove the key expiration time
  2. ttl key-name - View from the given key, how many seconds expired
  3. expire key-name seconds - let the specified key expire after a given number of seconds
  4. expireat key-name timestamp - given set the expiration time stamp given Unix
  5. pttl key-name - View from the given key expiration how many milliseconds (version> = 2.6)
  6. pexpire key-name milliseconds - let designated key expires after a given number of milliseconds (version> = 2.6)
  7. 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)

  1. BITOP AND destkey key [key ...], one or more logical key request and save the results to destkey.
  2. BITOP OR destkey key [key ...], one or more logical or key request, to save the results destkey.
  3. BITOP XOR destkey key [key ...], one or more logical XOR key request and save the results to destkey.
  4. 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

Published 59 original articles · won praise 22 · views 90000 +

Guess you like

Origin blog.csdn.net/Martin_chen2/article/details/104464359