[Minimalist] Redis installation and common commands under Windows

# Minimalist - Redis installation and common commands under Windows

1. Install Redis on Windows

1.1. Download the installation package

Github download address: https://github.com/tporadowski/redis/releasesNetwork
disk download address: Link: https://pan.baidu.com/s/1L7uSd8mCdfCzO2GAZ1Lcpw?pwd=wing

1.2. Installation.
After downloading, you will get a compressed package and unzip it directly.
Insert image description here
The file directory after decompression is as shown in the figure.
Insert image description here
Double-click it .redis-server.exeStart the Redis service.
Insert image description hereInsert image description here
Double-clickredis-cli.exeStart the Redis client. After the client is started, it will automatically connect to the previously started Redis service
Insert image description hereInsert image description here
and interact with instructions on the client page.

2. Common Redis commands

2.1. Redis data structure

Redis is a key-value database. The key is generally of String type, but the value types are diverse:
Insert image description here

2.2. General commands

General instructions are instructions that can be used for some data types. Common ones include:

  • KEYS: View all keys that match the template
  • DEL: delete a specified key
  • EXISTS: Determine whether the key exists
  • EXPIRE: Set the validity period for a key. The key will be automatically deleted when the validity period expires.
  • TTL: Check the remaining validity period of a KEY
  • Insert image description here

2.3. String command

  • SET: Add or modify an existing String type key-value pair
  • GET: Get the value of String type based on key
  • MSET: Add multiple String type key-value pairs in batches
  • MGET: Get multiple String type values ​​based on multiple keys
  • INCR: Let an integer key increase by 1
  • INCRBY: Let an integer key increase by itself and specify the step size. For example: incrby num 2 makes the num value increase by 2.
  • INCRBYFLOAT: Increment a floating-point number and specify the step size
  • SETNX: Add a String type key-value pair, provided that the key does not exist, otherwise it will not be executed.
  • SETEX: Add a String type key-value pair and specify the validity period

2.4. Hash command

  • HSET key field value: Add or modify the field value of hash type key
  • HGET key field: Get the field value of a hash type key
  • HMSET: Add field values ​​of multiple hash type keys in batches
  • HMGET: Get field values ​​of multiple hash type keys in batches
  • HGETALL: Get all fields and values ​​in a hash type key
  • HKEYS: Get all fields in a hash type key
  • HINCRBY: Let the field value of a hash type key increase automatically and specify the step size
  • HSETNX: Add a field value of a hash type key, provided that the field does not exist, otherwise it will not be executed.

2.5. List command

  • LPUSH key element…: Insert one or more elements to the left of the list
  • LPOP key: removes and returns the first element on the left side of the list, or returns nil if there is none
  • RPUSH key element…: Insert one or more elements to the right side of the list
  • RPOP key: Remove and return the first element on the right side of the list
  • LRANGE key star end: Returns all elements within a range of key stars
  • BLPOP and BRPOP: Similar to LPOP and RPOP, except that they wait for the specified time when there are no elements instead of returning nil directly.

2.6. Set command

  • SADD key member…: Add one or more elements to the set
  • SREM key member … : Remove the specified element from the set
  • SCARD key: Returns the number of elements in the set
  • SISMEMBER key member: Determine whether an element exists in the set
  • SMEMBERS: Get all elements in the set
  • SINTER key1 key2 ...: Find the intersection of key1 and key2
  • SDIFF key1 key2 ...: Find the difference between key1 and key2
  • SUNION key1 key2...: Find the union of key1 and key2

2.7. SortedSet command

  • ZADD key score member: Add one or more elements to the sorted set, and update its score value if it already exists
  • ZREM key member: delete a specified element in the sorted set
  • ZSCORE key member: Get the score value of the specified element in the sorted set
  • ZRANK key member: Get the ranking of the specified element in the sorted set
  • ZCARD key: Get the number of elements in the sorted set
  • ZCOUNT key min max: Counts the number of all elements whose score value is within a given range
  • ZINCRBY key increment member: Let the specified element in the sorted set increase by the specified increment value.
  • ZRANGE key min max: After sorting by score, get the elements within the specified ranking range
  • ZRANGEBYSCORE key min max: After sorting by score, get the elements within the specified score range
  • ZDIFF.ZINTER.ZUNION: Find the difference, intersection, and union

Guess you like

Origin blog.csdn.net/kkwyting/article/details/132752885