Skip to main content

Persistant decorator

Project description


Shelve Caching Decorator

Overview

This Python package provides a decorator leveraging Shelve for persistent caching. The decorator allows efficient caching of function results, improving performance by storing data persistently between program executions.

Features

  • Persistent Caching: Utilizes Shelve for persistent storage of cached function results.
  • Efficient Performance: Caches function results to avoid recomputation, enhancing performance for repeated calls.
  • Easy Integration: Simple decorator syntax for easy integration with existing functions.
  • Customizable: Easily configurable to cache functions with different argument combinations.

Installation

You can install the package using pip:

pip install shelve-caching-decorator

Usage

  1. Decorator Application: Use the @persistent_cache decorator to cache function results.

    from shelvecache import persistent_cache
    
    @persistent_cache("cache.db")
    def expensive_operation(x, y):
        # Your expensive computation here
        return x * y
    
    result = expensive_operation(2, 3)  # Function result cached
    
  2. Persistent Storage: The cached results are stored in the specified Shelve file ("cache.db" in the example above), ensuring persistence between program executions.

Examples

Check the examples directory for detailed usage examples.

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Feel free to customize and expand upon this README as needed for your repository!

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

shelve_cache-0.0.4.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

shelve_cache-0.0.4-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

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