-
-
Save onelharrison/a7f94cbbdb423a3a5cec0b3260466797 to your computer and use it in GitHub Desktop.
This file contains 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
""" | |
An oversimplified implementation of the Python interface for Redis | |
""" | |
class Redis: | |
def __init__(self, db=0): | |
self.db = db | |
self.data = {self.db: {}} | |
def get(self, key): | |
"""Gets the value associated with a key""" | |
return self.data.get(self.db, {}).get(key) | |
def set(self, key, value): | |
"""Sets a key-to-value association""" | |
self.data[self.db][key] = value | |
return True | |
def delete(self, key): | |
"""Deletes a key""" | |
del self.data[self.db][key] | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment