Skip to main content

MemoBox

MemoBox is a tiny, local, persistent memory store for Python programs.

It uses a JSON file, so there is no database server, account, API key, or setup required.

Install

pip install MemoBox

Quick start

from MemoBox import Brain

brain = Brain()

brain.remember("username", "sam")
brain.remember("theme", "dark")

print(brain.recall("username"))
# sam

print(brain.exists("theme"))
# True

brain.forget("theme")

Categories

brain.remember("python", "PyPI", category="interests")
brain.remember("robotics", "Arduino", category="interests")

print(brain.category("interests"))

Search

brain.remember("project", "MemoBox")
brain.remember("language", "Python")

print(brain.search("python"))

Custom storage path

brain = Brain("my_memory.json")

By default MemoBox stores data in .MemoBox/memory.json in the current working directory.

Expiring memory

You can store a value with an expiration time:

brain.remember("temporary", "hello", expires="1h")

Supported units:

  • s — seconds
  • m — minutes
  • h — hours
  • d — days

Examples: 30s, 10m, 2h, 7d.

API

Brain(path=None)

Creates a memory store.

remember(key, value, category=None, expires=None)

Stores or replaces a value.

recall(key, default=None)

Returns a value, or default if it does not exist.

forget(key)

Removes a key. Returns True if it existed.

exists(key)

Checks whether a non-expired key exists.

all(category=None)

Returns all stored values, optionally filtered by category.

category(name)

Returns all values in a category.

search(query)

Searches keys, categories, and stringified values.

clear(category=None)

Clears everything, or only one category.

Example

from MemoBox import Brain

brain = Brain()

brain.remember("username", "sam")
brain.remember("editor", "VS Code", category="tools")
brain.remember("language", "Python", category="tools")

print(brain.recall("username"))
print(brain.category("tools"))
print(brain.search("python"))

Development

Clone the repository and install the package in editable mode:

pip install -e ".[dev]"

Run tests:

pytest

Build the package:

python -m build

License

MIT

Download files

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

Source Distribution

memobox-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memobox-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: memobox-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.2

File hashes

Hashes for memobox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ddd6f9ab29ad7f7a337d5cd4266a79958b236e561f3b51e5558a46b560eda9bb
MD5 3a5bf601e624b24b5035b02390d4efe8
BLAKE2b-256 4bd0631e3ca92cb76bef998df7be36d36c09a1707f2f99b838a0d6c57670d974

See more details on using hashes here.

File details

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

File metadata

  • Download URL: memobox-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.2

File hashes

Hashes for memobox-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc6db1e972a443983ea2a525daf641b1efa380fae9253122f4efd98e10d608e8
MD5 18dcda23c289c202ff64447c95f74c0e
BLAKE2b-256 493712395cd8e5f441a9cea77bcb65571d32b98721938ccdde098a7b92202ff3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page