Auzre Microsoft Cloud Redis backend Stackexchange.redis use keyspacenotification to implement/handle some events before the cache expires

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.