The background,
When making a CASE of order payment, the order needs to be paid within a limited time. If the payment is not completed by the due date, the order will be invalid and the goods will be returned to the stock.
Second, the plan
This is a good case for using Redis’ Keyspace Notification
Keyspace notifications enable clients to subscribe to channels or modes to receive events that alter the Redis dataset in some way.
You can specify the type of notifications to be sent by the server by setting the notify-keyspace-events parameter in the redis redis.conf file. The following is a description of some parameters. This feature is disabled by default.
Three, two ways to enable key space notification
- Modifying a Configuration File
- Command line modification
Config set notify-keyspace-events KEA // Select * from KEA to KEA // select * from KEA to KEA // select * from KEA to KEA // select * from KEA to KEA // select * from KEA to KEA // select * from KEA to KEA // select * from KEA to KEA __keyevent@0__:expiredCopy the code
4. Listen for subscription expiration events
- The command line enables key space notification
- Listen for subscription expiration events with database 0
- Set key value to name value to the number of Lisi expire in 10 seconds
4.10 seconds later, the listener event is notified