Implemented LRU Cache Data Structure #54
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of new feature, or changes
Introduces a class (LRUCache) which implements a least-recently-used cache data structure. LRU cache is most commonly known for its popularity in operating systems applications for managing system memory caches.
This implementation accepts entries as key-value pairs. If a new entry would exceed the cache's configured maximum size, the least recently retrieved items are removed and destroyed from memory until there is enough room for the new one.
By default, items are considered to have size 1. However, you can specify a custom size function for how big to consider items. For example, if you are storing strings in your cache with a maximum limit of 20, you could specify that the cache should consider the string's length as its size, you would effectively have a cache with a maximum size of 20 bytes.
Checklist
Related Issues and Discussions
Implements #17
People to notify
@manrajgrover