Skip to content

API Reference parrot_tools.cache

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.cache

View source

Redis-based caching for Tool and Toolkit API responses.

Provides a lightweight cache layer that can be composed into any tool or toolkit to avoid redundant API calls within a configurable TTL.

Attribute DEFAULT_TOOL_CACHE_TTL

Class ToolCache

Redis-backed cache for tool/toolkit API responses.

Generates deterministic cache keys from tool name, method, and call parameters so that identical queries are served from Redis instead of hitting external APIs.

Parameter Type Default Description
prefix str 'tool_cache'
ttl int DEFAULT_TOOL_CACHE_TTL
redis_url Optional[str] None

Attributes:

Attribute Type Description
prefix Key prefix used in Redis to namespace tool cache entries.
ttl Default time-to-live in seconds for cached values.

Method ToolCache.get

Retrieve a cached value if it exists and has not expired.

get(tool_name: str, method: str, **params) -> Optional[Any]

Parameter Type Default Description
tool_name str Identifier of the tool.
method str Logical method or endpoint name.
**params {} Query parameters used to build the cache key.

Returns: Optional[Any] — The cached Python object, or None on cache miss.

Method ToolCache.set

Store a value in the cache with a TTL.

set(tool_name: str, method: str, value: Any, ttl: Optional[int] = None, **params) -> None

Parameter Type Default Description
tool_name str Identifier of the tool.
method str Logical method or endpoint name.
value Any The value to cache (must be JSON-serialisable).
ttl Optional[int] None Override TTL in seconds; defaults to instance TTL.
**params {} Query parameters used to build the cache key.

Method ToolCache.close

Close the underlying Redis connection.

close() -> None

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally