Skip to content

Instantly share code, notes, and snippets.

@AntiGameZ
Created December 6, 2012 14:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AntiGameZ/4224979 to your computer and use it in GitHub Desktop.
Save AntiGameZ/4224979 to your computer and use it in GitHub Desktop.
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
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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment