Last active
April 29, 2020 17:28
-
-
Save samueleresca/3a1bfd50b4f75a9c5be4d15b52ed2666 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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