Skip to content

API Reference parrot.bots.flows.core.storage.backends.redis

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

parrot.bots.flows.core.storage.backends.redis

View source

RedisResultStorage — Redis backend for crew/flow execution results (FEAT-147).

One key per execution: {collection}:{crew_name}:{ts_ms}, JSON value, optional TTL.

Alias CREW_RESULT_STORAGE_REDIS_TTL

Re-exported from parrot.conf.CREW_RESULT_STORAGE_REDIS_TTL.

Alias CREW_RESULT_STORAGE_REDIS_URL

Re-exported from parrot.conf.CREW_RESULT_STORAGE_REDIS_URL.

Class RedisResultStorage

Persist crew/flow execution results to Redis (one key per execution).

Key shape: {collection}:{crew_name}:{timestamp_ms} Value: JSON-encoded document (with default=str for non-serialisable fields). TTL: configurable via constructor or CREW_RESULT_STORAGE_REDIS_TTL (default 7 days).

Parameter Type Default Description
dsn Optional[str] None Redis DSN; defaults to CREW_RESULT_STORAGE_REDIS_URL.
ttl Optional[int] None Key TTL in seconds; 0 disables TTL. Defaults to CREW_RESULT_STORAGE_REDIS_TTL (604 800 s = 7 days).

Method RedisResultStorage.save

Write one execution record to Redis.

save(collection: str, document: dict[str, Any]) -> None

Parameter Type Default Description
collection str Logical collection name used as key prefix.
document dict[str, Any] Execution result document.

Method RedisResultStorage.fetch

Return all documents written under execution_id in collection.

Uses cursor-based SCAN (never KEYS) with pattern {collection}:{execution_id}:*, iterating until the cursor returns 0, then GETs each matched key.

fetch(collection: str, execution_id: str) -> list[dict[str, Any]]

Parameter Type Default Description
collection str Logical collection name used as key prefix.
execution_id str Crew-level execution id to match keys against.

Returns: list[dict[str, Any]] — List of parsed documents; empty list when nothing matches.

Raises:

  • Exception — Connection errors are logged then re-raised — unlike save(), read failures must not be silently swallowed.

Method RedisResultStorage.close

Release the Redis connection. Safe to call multiple times.

close() -> None

Method RedisResultStorage.list

List execution documents ordered by timestamp DESC.

Uses SCAN + MGET to fetch all keys under the collection prefix, then filters and paginates in-memory (Redis is not the recommended backend for high-volume reads — see spec Known Risks).

list(collection: str, filters: Optional[dict[str, Any]] = None, limit: int = 20, offset: int = 0) -> list[dict[str, Any]]

Parameter Type Default Description
collection str Logical collection name used as key prefix.
filters Optional[dict[str, Any]] None Optional in-memory filters — see :meth:_matches_filters.
limit int 20 Maximum number of documents to return.
offset int 0 Number of documents to skip (pagination), applied after filtering.

Returns: list[dict[str, Any]] — A list of execution documents, newest first. Empty list on error or when no documents match.

Method RedisResultStorage.get

Retrieve a single execution document by its Redis key.

get(collection: str, record_id: str) -> Optional[dict[str, Any]]

Parameter Type Default Description
collection str Logical collection name used as key prefix.
record_id str The Redis key identifying the document (as returned by list()'s "id" field).

Returns: Optional[dict[str, Any]] — The execution document, or None if not found, on error, or when record_id doesn't belong to collection (security: without this check a caller could GET an arbitrary Redis key outside this collection's namespace).

Method RedisResultStorage.delete

Delete a single execution document by its Redis key.

delete(collection: str, record_id: str) -> bool

Parameter Type Default Description
collection str Logical collection name used as key prefix.
record_id str The Redis key identifying the document.

Returns: bool — True if a key was deleted, False otherwise (including on error, or when record_id doesn't belong to collection — meth:get for why this check exists).

Method RedisResultStorage.count

Count execution documents matching the given filters.

count(collection: str, filters: Optional[dict[str, Any]] = None) -> int

Parameter Type Default Description
collection str Logical collection name used as key prefix.
filters Optional[dict[str, Any]] None Optional in-memory filters — see :meth:_matches_filters.

Returns: int — The number of matching documents, or 0 on error.

Alias ResultStorage

Re-exported from parrot.bots.flows.core.storage.backends.base.ResultStorage.

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