当前位置:网站首页>Redis related-01
Redis related-01
2022-06-25 03:44:00 【legend_ go】
Redis Basic relevance -01
One 、 What is? Redis?
Official description :
Redis It's open source (BSD The license ) Of , Data structure storage system in memory , It can be used as a database 、 Caching and message middleware . It supports multiple types of data structures , Such as character string (strings), hash (hashes), list (lists), aggregate (sets), Ordered set (sorted sets) And scope query , bitmaps, hyperloglogs and Geographical space (geospatial) Index radius query . Redis Built in Copy (replication),LUA Script (Lua scripting), LRU Driving events (LRU eviction), Business (transactions) And different levels of Disk persistence (persistence), And pass Redis sentry (Sentinel) And automatic Partition (Cluster) Provide high availability (high availability).
Personal understanding :
- It can be used as a database
- Used as a cache , Finally, it is persisted to the database
- Message oriented middleware implements the subscription and publication of messages
- Very fast read speed
Two 、Linux Lower installation Redis
1、 stay Redis Download the compressed package on the official website

2、 utilize XFTP The tool is uploaded to a folder on the remote server
Execute the following command :
# Unzip the file
tar -zxvf redis-6.2.6.tar.gz
# Enter the unzipped folder
cd redis-6.2.6
# compile
make
make install
# Get into src Folder
cd src
# start-up Redis
./redis-server ../redis.conf
# start-up Redis client
./redis-cli
Deployment success
3、 ... and 、Redis Common commands and basic data types
1、Redis key
| 1 | DEL key This command is used in key Delete... When it exists key. |
|---|---|
| 2 | DUMP key Serialization given key , And return the serialized value . |
| 3 | EXISTS key Check the given key Whether there is . |
| 4 | EXPIRE key seconds For a given key Set expiration time , In seconds . |
| 5 | EXPIREAT key timestamp EXPIREAT Function and EXPIRE similar , All for key Set expiration time . Difference is that EXPIREAT The time parameter accepted by the command is UNIX Time stamp (unix timestamp). |
| 6 | PEXPIRE key milliseconds Set up key In milliseconds . |
| 7 | PEXPIREAT key milliseconds-timestamp Set up key Time stamp of expiration time (unix timestamp) In milliseconds |
| 8 | KEYS pattern Find all that match the given pattern ( pattern) Of key . |
| 9 | MOVE key db Will be the current database of key Move to a given database db among . |
| 10 | PERSIST key remove key The expiration time of ,key Will last . |
| 11 | PTTL key Returns... In milliseconds key The remaining expiration time of . |
| 12 | TTL key In seconds , Return to a given key The remaining lifetime of (TTL, time to live). |
| 13 | RANDOMKEY Returns a random... From the current database key . |
| 14 | RENAME key newkey modify key The name of |
| 15 | RENAMENX key newkey Only when the newkey When there is no , take key Renamed as newkey . |
| 16 | [SCAN cursor MATCH pattern] [COUNT count] Iterate the database keys in the database . |
| 17 | TYPE key return key The type of value stored . |
2、String type
| 1 | SET key value Set the specified key Value |
|---|---|
| 2 | GET key Get specified key Value . |
| 3 | GETRANGE key start end return key The child character of the string value in |
| 4 | GETSET key value Will be given key The value of the set value , And back to key The old value (old value). |
| 5 | GETBIT key offset Yes key String value stored , Gets the bit on the specified offset (bit). |
| 6 | [MGET key1 key2…] Get all ( One or more ) Given key Value . |
| 7 | SETBIT key offset value Yes key String value stored , Sets or clears the bit on the specified offset (bit). |
| 8 | SETEX key seconds value Will value value Related to key , And will key The expiration time of is set to seconds ( In seconds ). |
| 9 | SETNX key value Only in key Set when not present key Value . |
| 10 | SETRANGE key offset value use value Parameter override given key String value stored , From the offset offset Start . |
| 11 | STRLEN key return key The length of the stored string value . |
| 12 | [MSET key value key value …] Set one or more... At the same time key-value Yes . |
| 13 | [MSETNX key value key value …] Set one or more... At the same time key-value Yes , If and only if all given key It doesn't exist . |
| 14 | PSETEX key milliseconds value This command and SETEX Command similar , But it's set in milliseconds key Survival time , Not like it SETEX Order that , In seconds . |
| 15 | INCR key take key The value of the number stored in is increased by one . |
| 16 | INCRBY key increment take key The stored value plus the given increment value (increment) . |
| 17 | INCRBYFLOAT key increment take key The stored value plus the given floating-point delta value (increment) . |
| 18 | DECR key take key Subtract one from the number stored in . |
| 19 | DECRBY key decrement key The stored value minus the given decrement value (decrement) . |
| 20 | APPEND key value If key Already exists and is a string , APPEND The order will specify value Append to the key Original value (value) At the end of . |
3、List type
| 1 | BLPOP key1 key2 ] timeout Move out and get the first element of the list , If there are no elements in the list, it will block the list until the wait timeout or pop-up elements are found . |
|---|---|
| 2 | BRPOP key1 key2 ] timeout Move out and get the last element of the list , If there are no elements in the list, it will block the list until the wait timeout or pop-up elements are found . |
| 3 | BRPOPLPUSH source destination timeout Pop up a value... From the list , Insert the pop-up element into another list and return it ; If there are no elements in the list, it will block the list until the wait timeout or pop-up elements are found . |
| 4 | LINDEX key index Get the elements in the list by index |
| 5 | LINSERT key BEFORE|AFTER pivot value Insert an element before or after a list element |
| 6 | LLEN key Get list length |
| 7 | LPOP key Move out and get the first element of the list |
| 8 | [LPUSH key value1 value2] Insert one or more values into the list header |
| 9 | LPUSHX key value Insert a value into the existing list header |
| 10 | LRANGE key start stop Get the elements in the specified range of the list |
| 11 | LREM key count value Remove list elements |
| 12 | LSET key index value Set the value of the list element through the index |
| 13 | LTRIM key start stop Trim a list (trim), That is to say , Let the list keep only the elements in the specified range , Elements that are not in the specified range will be removed . |
| 14 | RPOP key Remove the last element of the list , The return value is the removed element . |
| 15 | RPOPLPUSH source destination Remove the last element of the list , And add the element to another list and return |
| 16 | [RPUSH key value1 value2] Add one or more values... To the list |
| 17 | RPUSHX key value Add value to existing list |
4、Set type
| 1 | SADD key member1 member2] Add one or more members to the collection |
|---|---|
| 2 | SCARD key Get the number of members of the collection |
| 3 | [SDIFF key1 key2] Returns the difference between the first set and the others . |
| 4 | [SDIFFSTORE destination key1 key2] Returns the difference set of a given set and stores it in destination in |
| 5 | [SINTER key1 key2] Returns the intersection of a given set |
| 6 | [SINTERSTORE destination key1 key2] Returns the intersection of a given set and stores it in destination in |
| 7 | SISMEMBER key member Judge member Is the element a collection key Members of |
| 8 | SMEMBERS key Returns all members of the collection |
| 9 | SMOVE source destination member take member Elements from source The assembly moves to destination aggregate |
| 10 | SPOP key Remove and return a random element from the collection |
| 11 | [SRANDMEMBER key count] Returns one or more random numbers in a set |
| 12 | [SREM key member1 member2] Remove one or more members of the collection |
| 13 | [SUNION key1 key2] Returns the union of all given sets |
| 14 | [SUNIONSTORE destination key1 key2] The union of all given sets is stored in destination Collection |
| 15 | [SSCAN key cursor MATCH pattern] [COUNT count] Iterate over the elements in the collection |
5、Hash type
| 1 | [HDEL key field1 field2] Delete one or more hash table fields |
|---|---|
| 2 | HEXISTS key field Look at the hash table key in , Whether the specified field exists . |
| 3 | HGET key field Gets the value of the specified field stored in the hash table . |
| 4 | HGETALL key Gets the specified in the hash table key All fields and values of |
| 5 | HINCRBY key field increment Hash table key The integer value of the specified field in plus the increment increment . |
| 6 | HINCRBYFLOAT key field increment Hash table key The floating-point value of the specified field in plus the increment increment . |
| 7 | HKEYS key Get all the fields in the hash table |
| 8 | HLEN key Get the number of fields in the hash table |
| 9 | [HMGET key field1 field2] Get the value of all the given fields |
| 10 | [HMSET key field1 value1 field2 value2 ] There will be more than one field-value ( Domain - value ) Set to hash table key in . |
| 11 | HSET key field value Hash table key In the field field The value of the set value . |
| 12 | HSETNX key field value Only in the fields field When there is no , Set the value of the hash table field . |
| 13 | HVALS key Get all values in hash table . |
| 14 | [HSCAN key cursor MATCH pattern] [COUNT count] Iterate over the key value pairs in the hash table . |
6、 Ordered set ZSet
| 1 | [ZADD key score1 member1 score2 member2] Add one or more members... To an ordered collection , Or update scores of existing members |
|---|---|
| 2 | ZCARD key Get the number of members of the ordered set |
| 3 | ZCOUNT key min max Calculates the number of members of a specified interval fraction in an ordered set |
| 4 | ZINCRBY key increment member Add the increment... To the score of the specified member in the ordered set increment |
| 5 | [ZINTERSTORE destination numkeys key key …] Calculates the intersection of a given ordered set or sets and stores the result set in a new ordered set destination in |
| 6 | ZLEXCOUNT key min max Computes the number of members in the specified dictionary interval in an ordered collection |
| 7 | [ZRANGE key start stop WITHSCORES] Return the members in the specified interval of the ordered set through the index interval |
| 8 | [ZRANGEBYLEX key min max LIMIT offset count] Returns the members of an ordered set through a dictionary interval |
| 9 | [ZRANGEBYSCORE key min max WITHSCORES] [LIMIT] Returns the members of an ordered set in a specified interval through scores |
| 10 | ZRANK key member Returns the index of a specified member in an ordered collection |
| 11 | [ZREM key member member …] Remove one or more members of an ordered collection |
| 12 | ZREMRANGEBYLEX key min max Remove all members of a given dictionary interval from an ordered set |
| 13 | ZREMRANGEBYRANK key start stop Remove all members of a given rank range from an ordered set |
| 14 | ZREMRANGEBYSCORE key min max Remove all members of a given fraction interval from an ordered set |
| 15 | [ZREVRANGE key start stop WITHSCORES] Returns the members of a specified interval in an ordered set , Through the index , Scores go from high to low |
| 16 | [ZREVRANGEBYSCORE key max min WITHSCORES] Returns the members of the specified score range in an ordered set , Rank scores from high to low |
| 17 | ZREVRANK key member Returns the rank of a specified member in an ordered set , Members of an ordered set are decremented by fractions ( From big to small ) Sort |
| 18 | ZSCORE key member Back to the ordered set , The score of a member |
| 19 | [ZUNIONSTORE destination numkeys key key …] Computes the union of a given ordered set or sets , And store it in the new key in |
| 20 | [ZSCAN key cursor MATCH pattern] [COUNT count] Iterate over elements in an ordered set ( Include element members and element scores ) |
Four 、 Three special types
- Geospatial
- Hyperloglog
- Bitmap
1、Geospatial
- GEOADD
- GEODIST
- GEORADIUS
- GEOHASH
- GEOPOS
- GEORADIUSBYMMBER
Application scenarios : The man near the 、 Straight line distance, etc
2、Hyperloglog
| 1 | [PFADD key element element …] Add specified elements to HyperLogLog in . |
|---|---|
| 2 | [PFCOUNT key key …] Return to a given HyperLogLog The base estimate of . |
| 3 | [PFMERGE destkey sourcekey sourcekey …] Will be multiple HyperLogLog Merge into one HyperLogLog |
Application scenarios : Website UV(User View) User access , Available cardinality statistics
3、Bitmap
SETBIT
GETBIT
Application scenarios : User clocks in
Related articles :
- Redis-01
- What is? Redis
- stay Linux Lower installation Redis
- Redis Common commands and basic data types
- Three special types
- Redis-02
- Redis Implement basic transaction operations
- Redis Achieve optimistic lock
- adopt Jedis operation Redis
- adopt Jedis Understand the business
- SpringBoot Integrate Redis
- Customize RedisTemplate
- Redis-03
- Redis Configuration file details
- Persistence ——RDB operation
- Persistence ——AOF operation
- Redis Subscription Publishing
- Redis Cluster environment construction
- Master slave copy
- Manually configure the host during downtime
- Sentinel mode
- Cache penetration and avalanche
Reference link :
【 Madness theory Java】Redis The latest super detailed version of the tutorial is easy to understand
边栏推荐
- EasyNVR使用Onvif探测设备失败,显示“无数据”是什么原因?
- 老叶的祝福
- Maintenant, les oreilles vont entrer dans le métacosme.
- 同花顺证券开户是安全的吗?
- 中国天眼发现地外文明可疑信号,马斯克称星舰7月开始轨道试飞,网信办:APP不得强制要求用户同意处理个人信息,今日更多大新闻在此...
- AI writes its own code to let agents evolve! The big model of openai has the flavor of "human thought"
- Void* pointer
- Now, the ear is going into the metauniverse
- 一文搞懂php中的(DI)依赖注入
- Use xxl-job to customize tasks and schedule them
猜你喜欢

MySql安装教程

谷歌创始人布林二婚破裂:被曝1月已提出与华裔妻子离婚,目前身家6314亿美元...

Two way combination of business and technology to build a bank data security management system

How to play well in the PMP Exam?

MySql安裝教程

马斯克:推特要学习微信,让10亿人「活在上面」成为超级APP

签到功能完成03《ivx低代码签到系统制作》

后台页制作01《ivx低代码签到系统制作》

Randla net: efficient semantic segmentation of large scale point clouds

Void* pointer
随机推荐
We media do not know how to realize it? Sharing of 7 major realization methods
完美洗牌问题
Three key explanations of overseas e-commerce operation in 2022
后台页制作01《ivx低代码签到系统制作》
The sign in function completes 03 "IVX low code sign in system production"
MySQL installation tutorial
Amazon's other side in China
How does the administrator prohibit another person from kicking himself?
Rebeco: using machine learning to predict stock crash risk
Wuenda, the new course of machine learning is coming again! Free auditing, Xiaobai friendly
Please check the list of commonly used software testing tools.
马斯克被诉传销索赔2580亿美元,台积电公布2nm制程,中科院发现月壤中含有羟基形式的水,今日更多大新闻在此...
同花顺证券开户安全吗
CVPR大会现场纪念孙剑博士,最佳学生论文授予同济阿里,李飞飞获黄煦涛纪念奖...
可能是拿反了的原因
Is it safe to open an account on your mobile phone?
AI越进化越跟人类大脑像!Meta找到了机器的“前额叶皮层”,AI学者和神经科学家都惊了...
Now, the ear is going into the metauniverse
Tutorial on installing SSL certificates in Microsoft Exchange Server 2007
Nacos practice record