Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memedb-0.1.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

memedb-0.1.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file memedb-0.1.0.tar.gz.

File metadata

  • Download URL: memedb-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.10.7 Linux/5.19.0-35-generic

File hashes

Hashes for memedb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b4e11274609238609b19f070172eee10d16e754e8d94098fe71966d105cc6026
MD5 a611ddc6a9646124bb493032a764aa8a
BLAKE2b-256 4918e5b651f9884148fcfade71df1bb3e5f01a3be52ef138e837e84bd79757a0

See more details on using hashes here.

File details

Details for the file memedb-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: memedb-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.10.7 Linux/5.19.0-35-generic

File hashes

Hashes for memedb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3cc207dc0dc79dc476007163d38f1ddf64bdd9321d0377b57a5fcb3294ddb30b
MD5 3fe160530b3f19fcb4176404f8089cf4
BLAKE2b-256 44c9d662b764b31c7654b7d573afdb8adfeb83ec7561615f504218f560188eab

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page