Skip to content

Instantly share code, notes, and snippets.

@ekampf
Last active June 7, 2021 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekampf/384b740f76d7cf061adfb47f3cfebe23 to your computer and use it in GitHub Desktop.
Save ekampf/384b740f76d7cf061adfb47f3cfebe23 to your computer and use it in GitHub Desktop.
"""
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:
def __init__(self, size: int):
pass
def get(self, key) -> ?:
pass
def set(self, key, value) -> ?:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment