当前位置:网站首页>The most common usage scenarios for redis

The most common usage scenarios for redis

2022-06-23 21:48:00 FHAdmin

1、 Counter

It can be done to String Add and subtract , So as to realize the counter function .

Redis This kind of memory database has very high read and write performance , It is very suitable to store the number of frequent reads and writes .

2、 cache

Put hot data in memory , Set the maximum memory usage and the elimination strategy to ensure the cache hit rate .

3、 Session cache

have access to Redis To store session information of multiple application servers .

When the application server no longer stores the user's session information , It's no longer a state , A user can request any application server , This makes it easier to achieve high availability and scalability .

4、 Full page caching (FPC)

Except for basic conversations token outside ,Redis It's also very simple FPC platform .

With Magento For example ,Magento Provides a plug-in to use Redis As the full page cache backend .(java The whole project fhadmin.cn) Besides , Yes WordPress For users of ,Pantheon There is a very good plug-in wp-redis, This plugin will help you load the pages you have visited as quickly as possible .

5、 Lookup table

for example DNS Records are very suitable for use Redis For storage .

Lookup tables are similar to caching , It's also used Redis Quick search features . But the contents of the lookup table cannot be invalidated , And cached content can be invalidated , Because caching is not a reliable source of data .

6、 Message queue ( Release / Subscribe to the function )

List It's a two-way list , Can pass lpush and rpop Write and read messages

But it's best to use Kafka、RabbitMQ Wait for message middleware .

7、 Distributed lock implementation

In a distributed scenario , You cannot use locks in a stand-alone environment to synchronize processes on multiple nodes .

have access to Redis Self contained SETNX Command to implement distributed locks , besides , You can also use the official RedLock Distributed lock implementation .

8、 Other

Set Can achieve intersection 、 Operations such as Union , So as to achieve common friends and other functions .

ZSet Can achieve orderly operation , So as to achieve ranking and other functions .

原网站

版权声明
本文为[FHAdmin]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/12/202112211148022475.html