MemeDB - the fun and quirky side project for data storage, because sometimes it's good to take a break from the serious stuff!
Project description
MemeDB
MemeDB is a minimal in-memory key-value database that doesn't take itself too seriously. It's designed to be simple, lightweight, and fun to use.
Installation
Install MemeDB from PyPI:
pip install memedb
Quick Start
Create a new MemeDB instance and add some data:
from memedb import MemeDB
db = MemeDB()
db.set("key1", "value1")
db.set("key2", {"nested_key": "nested_value"})
Retrieve data by key:
value = db.get("key1")
print(value) # output: "value1"
nested_value = db.get("key2")["nested_key"]
print(nested_value) # output: "nested_value"
Delete data by key:
db.delete("key1")
Use transactions for atomicity:
with db.transaction():
db.set("key1", "new_value")
db.delete("key2")
Advanced Features
MemeDB also includes some more advanced features to make it more powerful:
Indexing
You can create an index for a specific key to speed up lookups:
db.index("name")
db.set("person:1", {"name": "Alice", "age": 30})
db.set("person:2", {"name": "Bob", "age": 25})
db.set("person:3", {"name": "Charlie", "age": 35})
result = db.lookup("name", "Alice")
print(result) # output: [{"name": "Alice", "age": 30}]
Querying
You can perform queries on the data using a simple SQL-like syntax:
db.set("person:1", {"name": "Alice", "age": 30})
db.set("person:2", {"name": "Bob", "age": 25})
db.set("person:3", {"name": "Charlie", "age": 35})
result = db.query("SELECT * FROM data WHERE age > 30")
print(result) # output: [{"name": "Charlie", "age": 35}]
Caching
You can add a cache to MemeDB to speed up access to frequently accessed data:
from memedb import Cache
cache = Cache(max_size=1000, ttl=3600) # cache up to 1000 items for 1 hour
db = MemeDB(cache=cache)
db.set("key1", "value1")
db.get("key1") # retrieves from cache
Contributions
Contributions are welcome! If you have a feature request or bug report, please open an issue on GitHub. If you'd like to contribute code, please fork the repository and submit a pull request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.