I myself am looking for such an option; Soon, I will soon begin my own implementation and publish it. Until then, here are some ideas you can try.
Runtime.Cache, if I remember correctly, can lead to invalidation of the cache based on absolute time, sliding time and key / file control.
First, find out which one you need to implement (I need absolute and moving, although I believe that moving will be more expensive)
Take a look at this link. alternative-to-concurrentdictionary-for-portable-class-library
My idea is to extend this class, so that each cache element adds / removes, we save / delete the cache key in the dictionary object with the expiration of time (for a sliding element we will update this expiration time when reading)
Then we have one main timer that checks this dictionary so often and expires depending on the time.
If you also want, you may have other keyword dependencies depending on the dictionary, so after the key has expired, you can expired in any other cache, depending on this.
Hope this helps in some way.
--- UPDATE
I managed to get around to writing my own implementation ... here you go ..
using System; using System.Collections.Generic; using System.Linq; using System.Reactive.Linq; using System.Threading; namespace RanaInside.CacheProvider { internal class CacheProvider : ICacheProvider { private IDictionary<object, CacheItem> _cache = new Dictionary<object, CacheItem>(); private IDictionary<object, SliderDetails> _slidingTime = new Dictionary<object, SliderDetails>(); private const int _monitorWaitDefault = 1000; private const int _monitorWaitToUpdateSliding = 500;
For the latest updates, visit my blog at
http://ranahossain.blogspot.co.uk/2014/01/cache-provider-for-portable-class.html