Metadata-Version: 2.1
Name: collections-cache
Version: 0.1.5
Summary: Collection 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.
License: MIT
Author: Luiz-Trindade
Author-email: luiz.gabriel.m.trindade@gmail.com
Requires-Python: >=3.12,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Description-Content-Type: text/markdown

# Collection Cache

`Collection Cache` is a simple and efficient caching solution built using SQLite databases. It allows for storing, updating, and retrieving data using unique keys, supporting complex data types through the use of `pickle`. It is designed to scale across multiple CPU cores by distributing the data across multiple SQLite databases.

## Features

- **Multiple SQLite databases**: Distributes data across multiple databases for better scalability.
- **Key-value store**: Store data as key-value pairs.
- **Supports complex data types**: Data is serialized using `pickle`, so you can store lists, dictionaries, and other complex Python objects.
- **Parallel processing**: Uses Python’s `multiprocessing` to handle large collections in parallel across multiple CPU cores.
- **Efficient data retrieval**: Retrieves stored data based on the key using an efficient search across the collection.

## Installation

To install the `Collection Cache` package, use [Poetry](https://python-poetry.org/) for managing dependencies.

1. Clone the repository:

    ```bash
    git clone https://github.com/Luiz-Trindade/collections_cache.git
    cd collection-cache
    ```

2. Install the package with Poetry:

    ```bash
    poetry install
    ```

## Usage

To use the `Collection Cache` package, you can import the main class `Collection_Cache` and interact with your collection.

### Example:

```python
from collection_cache import Collection_Cache

# Create a new collection
cache = Collection_Cache("STORE")

# Set a key-value pair
cache.set_key("alunos", ["Luiz", "Marcos", "João"])

# Get the value by key
students = cache.get_key("alunos")
print(students)  # Output: ['Luiz', 'Marcos', 'João']
```

### Methods:

- **`set_key(key, value)`**: Set a key-value pair in the cache. If the key already exists, it will be updated.
- **`get_key(key)`**: Retrieve the value associated with a key.
- **`create_collection()`**: Initializes the collection and sets up databases for key-value storage.
- **`get_all_keys()`**: Retrieves all keys from the collection.

## Development

To contribute or run tests:

1. Install development dependencies:

    ```bash
    poetry install --dev
    ```

2. Run tests:

    ```bash
    poetry run pytest
    ```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgements

- This package was created to demonstrate how to work with SQLite, `pickle`, and Python's `multiprocessing` module.


