Skip to content

Instantly share code, notes, and snippets.

@einarwh
Created February 28, 2013 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einarwh/5055376 to your computer and use it in GitHub Desktop.
Save einarwh/5055376 to your computer and use it in GitHub Desktop.
ExpirationCache outline.
/// <summary>
/// Simple LRU cache with expiring elements.
/// </summary>
public class ExpirationCache<TKey, TValue> where TValue : class
{
private readonly Dictionary<TKey, LinkedListNode<KeyValuePair<TKey, TimeStamped<TValue>>>> _dict
= new Dictionary<TKey, LinkedListNode<KeyValuePair<TKey, TimeStamped<TValue>>>>();
private readonly LinkedList<KeyValuePair<TKey, TimeStamped<TValue>>> _list
= new LinkedList<KeyValuePair<TKey, TimeStamped<TValue>>>();
private readonly TimeSpan _lifetime;
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment