Hi there

 

Azure Redis cache offers a publish/subscribe system for always-connected clients that needs cache item change notification

although this may help in lot of scenarios where a cache item is updated, some time such registration based architecture is not so easy to achieve or simple is not so comfortable to use

the nuget package TNX.Cache.Redis with new update 1.1.x, adds two interesting features, a gzip compression for data in high-speed configuration, and a local cache made with an internal MemoryCache from .NET 4 Runtime.Caching namespace, with a rock-solid built-in synchronization framework with cloud redis cache

here the complete usage example with such new features

 

var myConnectionString = “[xxx].redis.cache.windows.net,ssl=true,password=[xxx]”;

//cache setup
//connection string
CacheManager.RedisConnectionString = myConnectionString;

//set the short-lived object lifetime (default 1) used by GetOrDrillShort method
CacheManager.ShortRetentionMinutes = 1; //as default

//set the long-lived object lifetime (default 30) used by GetOrDrillLong method
CacheManager.LongRetentionMinutes = 30; //as default

//I can enable tracing
CacheManager.EmitsDebugTrace = false; //disabled

//I can enable gzip compression of cache data blob
CacheManager.EnableGZipDeflate = true;

//I can enable local caching with a built-in synchronization framework
CacheManager.EnableLocalCache = true;

while (true)
{
    DateTime time = CacheManager.GetOrDrill<DateTime>(OnCacheRedrill, TimeSpan.FromSeconds(5), “key”, “sub-key”);

    Console.WriteLine(“{0}”, time);
    Thread.Sleep(1000);
}

 

enjoy programming with this new assembly and with newly Redis cache

stay tuned

Lascia un commento