public
Last active

Yeah I would say this is just a repository pattern than cache repository, the data stored is in the cache thats all but as you said the http cache does need refactoring. Something like this would help, so that one doesnt have to cast back the item, and

  • Download Gist
ICache.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
public interface ICache
{
/// <summary>
/// Get the Type from Cache with key
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
T Get<T>(string key);
 
/// <summary>
/// Store the object with key into cache
/// </summary>
/// <param name="obj"></param>
/// <param name="key"></param>
void Store(object obj, string key);
 
/// <summary>
/// Remove the object from cache with key
/// </summary>
/// <param name="key"></param>
void Remove(string key);
/// <summary>
/// Store the object into cache with key and absolute expiration
/// </summary>
/// <param name="obj"></param>
/// <param name="key"></param>
/// <param name="expiry"></param>
void Store(object obj, string key, DateTime expiry);
 
/// <summary>
/// Store the object into cache with key and sliding expiration
/// </summary>
/// <param name="obj"></param>
/// <param name="key"></param>
/// <param name="timeSpan"></param>
void Store(object obj, string key, TimeSpan timeSpan);
 
/// <summary>
/// Clears the cache.
/// </summary>
void ClearCache();
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.