A decorator that optimizes function execution by caching results. With support for different eviction strategies (LFU, LRU, FIFO).
Project description
Module: memo
Description:
This module provides a memo decorator that implements a caching mechanism for function results. The goal is to optimize performance by avoiding redundant calculations.
Features:
- Cache: Stores function call results in a local file.
- Eviction strategies: Supports various eviction strategies (LRU, LFU, FIFO) to manage cache size.
- Serialization: Uses serialization to store various data types in the cache.
- Synchronization: Implements synchronization mechanisms to ensure cache integrity in multi-threaded environments.
Usage:
from memo import memo
@memo(strategy='lru', max_size=500)
def fibonacci(n):
if n < 2:
return n
return fibonacci(n-1) + fibonacci(n-2)
```
**Decorator parameters**:
* strategy: Eviction strategy (lru, lfu, fifo).
* max_size: Maximum cache size.
* ttl: Time-to-live of items in the cache (in seconds).
* Internal structure:
* cache_class: Class representing the cache (LRUCache, LFUCache, FIFOCache).
* evictor: Object responsible for managing cache item eviction.
* serialize/deserialize: Functions for serializing and deserializing data.
* cache_lock: Synchronization mechanism for cache access.
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 memocache-0.0.3.tar.gz.
File metadata
- Download URL: memocache-0.0.3.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67842e87193fe6c92f0b87d906d82155b2354eaccb0b85d98b4dd9b76ce26acb
|
|
| MD5 |
56aa14fc114290e445d02add510cae28
|
|
| BLAKE2b-256 |
49dede47caacaaba7c6a68ade3ad1fae8866a2efc81efd708fbf85cb275f1bec
|
File details
Details for the file memocache-0.0.3-py3-none-any.whl.
File metadata
- Download URL: memocache-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbdb3f9d558c536f90ba60b88936468a125ef7eb58703e7bb94786904856f86a
|
|
| MD5 |
59cd181a172860077beef09c0e38092f
|
|
| BLAKE2b-256 |
973e689646faa9108328b49981a89ef17bb8c1ada8ade7358bc3789881e2d2c4
|