, , ICacheService. Dependency Injection - factory, - , .
, , , .
1). " DummyCacheService", , , .
2). AspCacheService, HttpContext.Current.Cache
3). MemCacheService.
4). Windows Azure, AzureCacheService...
The great thing about this strategy is that we did not need to change one line of code in our application code ... we just wrote a new service, obtained from ICacheService , and we tested it completely outside the application, and as soon as it was ready, we used the Windsor / container Castle DI to enter our production site.
For reference, here is the interface we use ... it can be changed according to your needs, but it works great for us
public interface ICacheService
{
void Flush();
void Add(string key, object item, int expirationInSeconds);
void Add(string key, object item, int expirationInSeconds, CacheItemPriority priority);
void Add(string key, object item, DateTime absoluteExpiration);
void Add(string key, object item, DateTime absoluteExpiration, CacheItemPriority priority);
void Add(string key, object item, TimeSpan slidingExpiration);
void Add(string key, object item, TimeSpan slidingExpiration, CacheItemPriority priority);
object Get(string key);
object Remove(string key);
T Get<T>(string key);
IList<string> GetCacheKeys();
bool ContainsData(string key);
}