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.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file memocache-0.0.1.tar.gz.

File metadata

  • Download URL: memocache-0.0.1.tar.gz
  • Upload date:
  • Size: 5.6 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.1.tar.gz
Algorithm Hash digest
SHA256 7da34b10b769ae84c085a697c3ea60fe81089c6d7b8d35cf0bdc4b430dce9599
MD5 844a9e3a5a516e2de1e743c1987487a9
BLAKE2b-256 804bd77577b79c4afb64a83679bac9548393c8504e71333acd59a65b5406234e

See more details on using hashes here.

File details

Details for the file memocache-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: memocache-0.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 080c7eb7022473b89c7115e2ec30e78396bc7c7c5a4bdb5a6b4665f2fda446b9
MD5 c512ad21bbde4fa140c34b72cd61099c
BLAKE2b-256 937b6881f79ebad7d825e2966d4f7d9bf0b781ddf040e2d4227dda129b0d5314

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