Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memocache-0.0.3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

memocache-0.0.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

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

Hashes for memocache-0.0.3.tar.gz
Algorithm Hash digest
SHA256 67842e87193fe6c92f0b87d906d82155b2354eaccb0b85d98b4dd9b76ce26acb
MD5 56aa14fc114290e445d02add510cae28
BLAKE2b-256 49dede47caacaaba7c6a68ade3ad1fae8866a2efc81efd708fbf85cb275f1bec

See more details on using hashes here.

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

Hashes for memocache-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cbdb3f9d558c536f90ba60b88936468a125ef7eb58703e7bb94786904856f86a
MD5 59cd181a172860077beef09c0e38092f
BLAKE2b-256 973e689646faa9108328b49981a89ef17bb8c1ada8ade7358bc3789881e2d2c4

See more details on using hashes here.

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