Skip to main content

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 multiprocessing module 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.

  1. Clone the repository:

    git clone https://github.com/Luiz-Trindade/collections_cache.git
    cd collections-cache
    
  2. 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:

  1. Install development dependencies:

    poetry install --dev
    
  2. 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's multiprocessing module.
  • Created by: Luiz Trindade.

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

collections_cache-0.2.7.20250303.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

collections_cache-0.2.7.20250303-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file collections_cache-0.2.7.20250303.tar.gz.

File metadata

  • Download URL: collections_cache-0.2.7.20250303.tar.gz
  • Upload date:
  • Size: 4.3 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

Hashes for collections_cache-0.2.7.20250303.tar.gz
Algorithm Hash digest
SHA256 1a2e8844ec283420ba9a4eb092ef1d1238c754d7d2cd3a28acce0f1c64d4574a
MD5 5ed32859619d615cd2585ab18c9ef795
BLAKE2b-256 d3ba7be13c07ce789702e8e7e9aedc81728e989e4148a308b25dc5d611b44755

See more details on using hashes here.

File details

Details for the file collections_cache-0.2.7.20250303-py3-none-any.whl.

File metadata

File hashes

Hashes for collections_cache-0.2.7.20250303-py3-none-any.whl
Algorithm Hash digest
SHA256 52daffe2aa78a9dfd55dcf93da6737598493c60c15a28f4580e863805229b94d
MD5 9bae20523923d541b7d8cc6b95e30911
BLAKE2b-256 339a257c8b5002fe3e1973c1c8b8d8207815754ab46569e184ab8b00e3624d43

See more details on using hashes here.

Supported by

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