First, publish the subscription message
A publish Subscription (PUB/SUB) is a message communication pattern that is primarily designed to decouple the coupling between a message publisher and a subscriber, and Redis acts as a pub/sub server, with the ability to route messages between subscribers and publishers. Subscribers can subscribe to Redis server for the type of message they are interested in by using the Subscribe and Psubscribe commands, and Redis is calling the information type Channel. When a publisher sends a specific type of information to Redis server through the Publish command, all clients subscribing to that type of information receive this message.
Example
First, the client 1 subscribes to channel TV1, client 2 subscribes to channel TV2, and the host sends a message to two channels TV1 and TV2 respectively:
Client 1 also receives a message sent to TV1, such as:
Client 2 also receives messages sent to TV1 and TV2, such as:
second, virtual memory
Redis's virtual memory is not the same as the operating system's virtual memory, but the idea and purpose are the same. is to temporarily swap infrequently accessed data from memory to disk , freeing up valuable memory for other data that needs to be accessed. Especially for memory databases such as Redis, memory is never enough. In addition to splitting the data into multiple Redis 5erver. Another way to improve database capacity is to use virtual memory to swap infrequently accessed data to disk.
Configuration
Configuration is simple, open the configuration file to modify the value of the VM properties, such as:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
redis--Publish subscription Mode & virtual memory