Skip to main content

A Redis cache decorator for crewai tasks/flows.

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

crewai-cache-hook

A Redis-based cache decorator for crewai tasks or flows.

Features

  • Add cache capability to functions/tasks via a decorator
  • Checks Redis cache before execution, returns cached result if hit
  • Automatically writes result to Redis cache after execution
  • Supports custom cache key, expiration time, and Redis connection parameters

Installation

pip install redis

Quick Start

  1. Copy cache_hook.py to your project directory
  2. Use the decorator in your crewai task/flow
from cache_hook import cache_hook

@cache_hook(expire=600)  # Cache for 10 minutes
def my_task(x, y):
    # Your task logic
    return x + y

Advanced Usage

To customize Redis connection parameters:

from cache_hook import CacheHook

my_cache = CacheHook(host='127.0.0.1', port=6379, db=0)
cache_hook = my_cache.cache_hook

@cache_hook(expire=120)
def another_task(a, b):
    ...

Parameters

  • expire: Cache expiration time (seconds)
  • cache_key_func: Custom function to generate cache key (optional)
  • host/port/db/password: Redis connection parameters

Notes

  • Uses pickle for result serialization by default. Ensure your result objects are pickle-serializable.
  • Suitable for crewai tasks, flows, or regular Python functions.

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

crewai_cache_hook-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crewai_cache_hook-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file crewai_cache_hook-0.1.0.tar.gz.

File metadata

  • Download URL: crewai_cache_hook-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for crewai_cache_hook-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6f4470b08fb05b6abd6300d4469b6c2854c02ab17dd382ca3c8c4ec355878b9c
MD5 802386b2cfab4a3d5d5ec5b00de595a4
BLAKE2b-256 d479160763d179281679d917431d4866247b21b2900fd0732c9bccf846acb5c4

See more details on using hashes here.

File details

Details for the file crewai_cache_hook-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for crewai_cache_hook-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 711a399e1b77e247266f76553377834d7be89c1cc648a4f81813e352d49e7af6
MD5 7d97bad78c8a5ca2e468fe4255bc1da0
BLAKE2b-256 e5b56203b2e6e5e1ca01365c68cc810f7b8533cc050f11bef6967d8fe9551aae

See more details on using hashes here.

Supported by

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