Skip to content

API Reference parrot_tools.massive.cache

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

parrot_tools.massive.cache

View source

Cache layer for MassiveToolkit with per-endpoint TTLs.

Different endpoints have different data freshness requirements:

  • Options Greeks change tick-by-tick (15 min TTL for decision cadence)
  • Short Interest updates bi-monthly (12 hour TTL)
  • Short Volume updates daily (6 hour TTL)
  • Earnings data is quarterly (24 hour TTL)
  • Analyst Ratings are sporadic (4 hour TTL)

Alias DEFAULT_TOOL_CACHE_TTL

Re-exported from parrot_tools.cache.DEFAULT_TOOL_CACHE_TTL.

Class MassiveCache

Cache layer for MassiveToolkit with per-endpoint TTLs.

Wraps the existing ToolCache infrastructure to provide endpoint-aware caching with appropriate TTLs based on data freshness requirements.

Parameter Type Default Description
redis_url str | None None Optional Redis URL (uses default from config if not provided)
default_ttl int DEFAULT_TOOL_CACHE_TTL Default TTL for endpoints not in TTLS dict

Method MassiveCache.get_ttl

Get the TTL for a specific endpoint.

get_ttl(endpoint: str) -> int

Parameter Type Default Description
endpoint str API endpoint name

Returns: int — TTL in seconds

Method MassiveCache.get

Get cached result for endpoint with given parameters.

get(endpoint: str, **params) -> dict | None

Parameter Type Default Description
endpoint str API endpoint name (e.g., "options_chain", "short_interest")
**params {} Query parameters used for this API call

Returns: dict | None — Cached dict if hit, None if miss

Method MassiveCache.set

Cache result with endpoint-specific TTL.

set(endpoint: str, data: dict, ttl: int | None = None, **params) -> None

Parameter Type Default Description
endpoint str API endpoint name
data dict Data to cache (must be JSON-serializable)
ttl int | None None Optional override for endpoint TTL
**params {} Query parameters used for this API call

Method MassiveCache.invalidate

Invalidate a specific cache entry.

Note: This requires direct Redis access since ToolCache doesn't expose a delete method. Returns False if not supported.

invalidate(endpoint: str, **params) -> bool

Parameter Type Default Description
endpoint str API endpoint name
**params {} Query parameters

Returns: bool — True if invalidated, False if not supported or failed

Method MassiveCache.invalidate_endpoint

Invalidate all cache entries for an endpoint.

Uses Redis SCAN to find and delete all keys matching the endpoint pattern.

invalidate_endpoint(endpoint: str) -> int

Parameter Type Default Description
endpoint str API endpoint name

Returns: int — Number of keys deleted

Method MassiveCache.close

Close the underlying cache connection.

close() -> None

Alias ToolCache

Re-exported from parrot_tools.cache.ToolCache.

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