Cache Adapter 4.1 Released
The latest version of cache adapter has now been released and is available via Nuget or you can download the source code here.
Note: For those who don’t know what cache adapter is, you can check out the wiki here or you can look at some previous blog posts here which also has links to other posts.
The nuget packages for the core component and the package with all configuration and code examples are:
- Glav.CacheAdapter.Core - binary only ( http://www.nuget.org/packages/Glav.CacheAdapter.Core/ )
- Glav.CacheAdatper - binary, configuration examples, code examples. ( http://www.nuget.org/packages/Glav.CacheAdapter/ )
- Bitbucket code repository - complete source code for the CacheAdapter ( https://bitbucket.org/glav/cacheadapter )
Please note: This release would not have been possible without contributions from the community, most notably Katrash. Your contributions are much appreciated even if my response and eventual action is somewhat slow.
Updated: I made an error with Glav.CacheAdapter.Core 4.1.0 package which included the readme, config transforms etc. This has now been fixed with the Nuget packages 4.1.1. There is no assembly change in these oackages, which remains at 4.1.0.
What is in this release
This is only a relatively minor release but does contain some useful additions, as well as addressing some outstanding issues. The list of items addressed in this release are:
- Targetting .Net 4.5.
- Async method support.
- Configurable Logging
Targetting .Net 4.5
CacheAdapter nuget package now only targets .Net 4.5 to allow the removal of Microsoft.Bcl packages from the dependency list which caused package bloat and was a much requested change for many users. These packages were only required when targetting versions of .Net prior to .Net 4.5 as the StackExchange.Redis package had these listed as dependencies. Glav.CacheAdapter depends upon StackExchange.Redis for its Redis support.
Async Method Support
Async method support is now available for all ‘Get’ CacheProvider operations.
For all ‘Get’ operations that also implicitly add data to the cache when a cache miss occurs, there are now the async equivalents of these methods that will return a ‘Task<T>’.
So if previously you did something like:
var data = cacheProvider.Get<MyDataClass>(cacheKey, DateTime.Now.AddDays(1), () =>
{
return dataStore.PerformQuery();
};
you can now use the async form of that method that returns a task. Using the above example, this would now become:
var data = await cacheProvider.GetAsync<MyDataClass>(cacheKey, DateTime.Now.AddDays(1), () =>{
return dataStore.PerformQueryAsync();
};
Configurable logging.
You can now disable/enable logging, log only errors, or log informational items which also includes errors. Previously this was left up to consumers to implement their own ILogging interface to allow whatever degree of confurability they want. As of this release, you now get the ability to perform basic configuration on the included logging component. This is specifed in configuration (like everything else), in the form:
- <add key="Cache.LoggingLevel" value="Information"/> – This logs everything and is the default. This is how prior versions operated.
- <add key="Cache.LoggingLevel" value="ErrorsOnly"/> – As the name suggests, only error information is logged.
- <add key="Cache.LoggingLevel" value="None"/> – Nothing is logged.
That is about it for the changes. Hope you find them useful. Feel free to let me know any suggestions or even perhaps create a pull request for any features you think are valuable additions.