A minimal data storage and retrieval library.
Project description
Stashbox
Stashbox is a lightweight Python library designed for minimalistic data storage and retrieval. It allows you to easily stash (store) and fetch (retrieve) data with support for optional persistence, compression, expiry, and logging.
Features
- Simple API: Stash and fetch data with concise, easy-to-understand commands.
- Persistence: Optionally persist data to disk, allowing it to survive program restarts.
- Compression: Reduce the storage size of your data with built-in compression.
- Expiry: Set an expiry time for stashed data, automatically removing it when it expires.
- Logging: Keep track of stashed operations with optional logging.
Installation
You can install Stashbox using pip:
pip install stashbox
Usage
Basic Usage
import stashbox
# Stash data
stashbox.stash('my_key', 'Hello, World!')
# Fetch data
data = stashbox.fetch('my_key')
print(data) # Outputs: Hello, World!
Advanced Usage
Stashing Data with Persistence
stashbox.stash('my_key', 'Persistent Data', persist=True)
Fetching Data
data = stashbox.fetch('my_key')
Setting Expiry for Data
stashbox.stash('temporary_data', 'This will expire', expiry=3600) # Expires in 1 hour
Compressing Data
stashbox.stash('compressed_key', 'This data is compressed', comp=True)
Deleting Data
stashbox.delete('my_key')
Listing All Stashed Data
all_data = stashbox.list_all()
print(all_data)
Retrieving Metadata
metadata = stashbox.info('my_key')
print(metadata)
Customizing Default Settings
stashbox.set_default_expiry(86400) # Default expiry to 1 day
stashbox.set_default_persistence(True) # Enable persistence by default
stashbox.set_default_compression(True) # Enable compression by default
stashbox.set_default_logging(True) # Enable logging by default
Contributing
Contributions are welcome! Please feel free to submit a Pull Request on GitHub.
License
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
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.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stashbox-0.1.0.tar.gz.
File metadata
- Download URL: stashbox-0.1.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.6 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64047173f773f82d7b38f4be41bdb875b66da39f61933bd974c9975d33663574
|
|
| MD5 |
469553530b07daf514b1da7c4de36344
|
|
| BLAKE2b-256 |
29756ed11a72a4b9f8745459776b8f2f68d7e69b8174f93ff5dc50db6e6a0fa6
|
File details
Details for the file stashbox-0.1.0-py3-none-any.whl.
File metadata
- Download URL: stashbox-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.6 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adc4039254bb4f788c9fe4124438dd13a2d247120427d36bca59f8f948966883
|
|
| MD5 |
9ed298a542342bdcc3c1d62c7dbb2d37
|
|
| BLAKE2b-256 |
bcebfb33923e52055b2b67c3f569a40a865d6130f000e88477c06f5fd0d74532
|