Creating cache services instead of providers
The Provider Model is common in .NET Framework as we might know some like RoleProvider, ProfileProvider, MembershipProvider and so on. I want have something similar for cache, my application can switch to a different cache system just by changing some configuration element. So Provider Model seems a good approach to follow.
1. A simple Cache Service interface
T Get<T>(string key) where T : class; bool Set<T>(string key, T value) where T : class; bool Set<T>(string key, T value, TimeSpan expiry) where T : class; bool Remove(string key);
2. An InMemoryCache implementation
This implementor uses the system MemoryCache, it is an Adapter to MemoryCache
3. A RedisCache implementation