LRU Cache
This is an implementation of an in memory LRU Cache!
For some example uses see main.go for some trivial examples or the tests TestCache_GetItem and TestCache_AddItem
This cache uses the Write Through policy.
Areas of improvements
- There definitely can be more test cases added since caching can get quite complicated
- The test cases shown show a minimal viable cache and provide coverage for the basic cases
- This cache does
O(n)
retrieval for the LRU. To implement aO(log(n)
solution refer to the comment in this file - The code is more strict towards the current Write Through policy, so changing to a new policy would require some refactoring, though not much and I did comment where some of those changes would be like here