The story of PostgreSQL and its friends-Redis
Read and write Redis directly in PostgreSQL.
Many benefits, can reduce the complexity of application layer design, reduce the number of interactions, reduce Rt.
Examples of application scenarios:
.1. Improve database performance by using Redis as a level two cache for PostgreSQL.
For example, in production there are multiple Redis hosts or clusters, using Redis to extend the two-level cache capability of PG, reducing the need for IO.
This can be done in the form of a trigger, when data is inserted or updated, and inserted or updated to Redis.
Removed from Redis when deleted.
When used as a level two cache, the update operates Redis directly from PostgreSQL to reduce the total number of interactions.
Querying Redis directly or querying Redis from PostgreSQL is OK, and if it's optimistic, it's okay to check from Redis, and if it's pessimistic, read from PostgreSQL and write to Redis.
.2. For example, to calculate the count number of records, when data is inserted or deleted, the record is either self-increment or decrement.
.3. Use to label data, such as data storage, according to the user ID of the data and the behavior of the recorded habits of labeling, the label information directly into Redis, as a real-time tagging system.
Postgresql+redis Cache