Https://github.com/rustd/RedisSamples/blob/master/HelloWorld/KeySpaceNotifications.cs
You can see the official demo code provided above to understand how to use the
Auzre above need to set Keyspace notifications with "KXG"
Then subscribe when the project starts, for example, using Nancy, adding a subscription to the Boostrapper boot
Personal Sample code:
var db = CacheManager.Connection.GetDatabase (); var subscriber = CacheManager.Connection.GetSubscriber (); Subscriber. Subscribe ("[email protected]__:*"async (channel, value) = { if (value.) Equals ("expired")) await Cacheexpire.keyexpire (channel); });
Here I only do the cache expiration processing, so only to judge the expired
In the Cacheexpire.keyexpire channel, the channel is passed in order to get the current expired key for subsequent processing
Auzre Microsoft Cloud Redis backend Stackexchange.redis use keyspacenotification to implement/handle some events before the cache expires