Skip to content

Instantly share code, notes, and snippets.

@samueleresca
Last active April 29, 2020 17:28
Show Gist options
  • Save samueleresca/3a1bfd50b4f75a9c5be4d15b52ed2666 to your computer and use it in GitHub Desktop.
Save samueleresca/3a1bfd50b4f75a9c5be4d15b52ed2666 to your computer and use it in GitHub Desktop.
public class LRUCacheSemaphore<T>
{
...
public object Get(int key)
{
_sem.Wait();
if (!_records.ContainsKey(key)) return null;
_freq.Remove(key);
_freq.AddLast(key);
_sem.Release();
return _records[key].CacheValue;
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment