collections-cache is a Python package for managing data collections across multiple SQLite databases. It allows efficient storage, retrieval, and updating of key-value pairs, supporting various data types serialized with pickle. The package uses parallel processing for fast access and manipulation of large collections.
Project description
collections-cache
collections-cache is a simple and efficient caching solution built with SQLite databases. It allows storing, updating, and retrieving data using unique keys while supporting complex data types through pickle. Designed to scale across multiple CPU cores, it distributes data across multiple SQLite databases for improved performance.
Features
- Multiple SQLite databases: Distributes data across multiple databases for better scalability.
- Key-value store: Stores data as key-value pairs.
- Supports complex data types: Data is serialized using
pickle, allowing you to store lists, dictionaries, and other Python objects. - Parallel processing: Utilizes Python’s
multiprocessingmodule to handle large collections in parallel across multiple CPU cores. - Efficient data retrieval: Retrieves stored data efficiently based on the key.
- Cross-platform: Works on Linux, macOS, and Windows.
Installation
To install the collections-cache package, use Poetry to manage dependencies.
-
Clone the repository:
git clone https://github.com/Luiz-Trindade/collections_cache.git cd collections-cache
-
Install the package with Poetry:
poetry install
Usage
To use the collections-cache package, import the main class Collection_Cache and interact with your collection.
Example
from collections_cache import Collection_Cache
# Create a new collection
cache = Collection_Cache("STORE")
# Set a key-value pair
cache.set_key("products", ["apple", "orange", "onion"])
# Get the value by key
products = cache.get_key("products")
print(products) # Output: ['apple', 'orange', 'onion']
Methods
set_key(key, value): Stores a key-value pair in the cache. If the key already exists, its value is updated.set_multi_keys(key_and_value): Stores a multi key-value pair in the cache. If the key already exists, its value is updated.get_key(key): Retrieves the value associated with a key.delete_key(key): Removes an existing key from the cache.keys*: Returns all stored keys.
Development
To contribute or run tests:
-
Install development dependencies:
poetry install --dev
-
Run tests:
poetry run pytest
License
This project is licensed under the MIT License – see the LICENSE file for details.
Acknowledgements
- This package was created to demonstrate how to work with SQLite,
pickle, and Python'smultiprocessingmodule. - Created by: Luiz Trindade.
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 collections_cache-0.2.4.dev20250303.tar.gz.
File metadata
- Download URL: collections_cache-0.2.4.dev20250303.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.11.0-17-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b388eb33e4d292e68e0a02e58294f84ef36772fed08ebed4431f0695b7d5522c
|
|
| MD5 |
39b4b863867b31addba41d2628ac323b
|
|
| BLAKE2b-256 |
1bee3810b88463d41a4e1cd97478148f69ad020f9afb9c05093c1c2eafefb335
|
File details
Details for the file collections_cache-0.2.4.dev20250303-py3-none-any.whl.
File metadata
- Download URL: collections_cache-0.2.4.dev20250303-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.11.0-17-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d7d63ae9783792751a06c79930a1278fec97cdb384059589cd81a8fa6016925
|
|
| MD5 |
2dd4804de55f8e31306900ebf0168101
|
|
| BLAKE2b-256 |
177aba99a63900a09bb6a81d2ae48f9bb745a0a561cfc32e7c61544cdd81f2f6
|