Skip to content

Instantly share code, notes, and snippets.



Last active May 15, 2018
What would you like to do?
// Implement a cache class that stores given item. The cache is limited to a given `size` and will discard the
// least recently used item if it needs the space.
// Clearly document design choices, algorithm and possible optimizations.
// While we require you to implement one memory allocation algorithm,
// also document future looking design considerations.
// Implementation Notes:
// * While the interface below is written in Python, feel free to implement the Cache in the language of your choosing.
// * Do not use standard library data structures - write your own. (like Python's `collections` module etc.)
// *** Requirements ***
// 1. Working code (obviously).
// 2. Unit tests (using a unit testing library of your choosing)
// 3. Documentation (as describe in the 2nd paragraph above)
class Cache(object):
def __init__(self, size):
def get(self, key):
def set(self, key, value):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.