Skip to content

API Reference parrot_formdesigner.services.partial_saves

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

parrot_formdesigner.services.partial_saves

View source

Redis-backed ephemeral storage for partial form answers.

Provides PartialSaveStore — a service that stores work-in-progress form answers in Redis under the key namespace parrot:partial:{form_id}:{session_id}.

Design mirrors FormCache (services/cache.py) with these differences:

  • No in-memory cache tier: partial saves are per-session ephemeral data that is not worth local caching across requests.
  • Key includes session_id for isolation between concurrent users.
  • save() implements merge-on-write: new answers are merged over cached answers (last-write-wins), and the TTL is refreshed on every write.

Alias PartialFormData

Re-exported from parrot_formdesigner.core.partial.PartialFormData.

Class PartialSaveStore

Redis-backed ephemeral storage for partial form answers.

Each save merges the new answers over any cached answers (last-write-wins) and refreshes the TTL for the entire entry. Different session_id values produce independent cache entries, ensuring session isolation.

If no redis_url is provided (or Redis is unavailable), the service operates in a no-op mode: save() returns the merged state without persisting it, get() returns None, and delete() returns False. This allows callers to handle graceful degradation.

Parameter Type Default Description
ttl_seconds int 3600 Time-to-live in seconds for cached entries. Default: 3600 (1 hour). Each save() call refreshes the TTL.
redis_url str | None None Optional Redis connection URL, e.g. "redis://localhost:6379". If None, Redis is not used.

Method PartialSaveStore.save

Merge answers into the cached partial and return the updated state.

New values override existing cached values (last-write-wins). The TTL for the entire cache entry is refreshed on every call.

If Redis is unavailable, the merged state is returned without persisting (in-process only — survives the current request but not across requests).

save(form_id: str, session_id: str, answers: dict[str, Any]) -> PartialFormData

Parameter Type Default Description
form_id str Form identifier.
session_id str Session identifier (uniquely scopes the cache entry).
answers dict[str, Any] Mapping of field_uid (stringified UUID) to new values (FEAT-393 / TASK-2003 — re-keyed at the FormAPIHandler boundary so a mid-session field_id rename never orphans a saved answer). This service remains schema-agnostic: it merges whatever keys it is given and does not resolve or validate them. Merged over any existing cached data.

Returns: PartialFormData — PartialFormData representing the full merged state after the save.

Method PartialSaveStore.get

Retrieve cached partial answers.

Returns None if the entry is absent or has expired. Redis handles TTL expiry natively — no client-side TTL check is needed.

get(form_id: str, session_id: str) -> PartialFormData | None

Parameter Type Default Description
form_id str Form identifier.
session_id str Session identifier.

Returns: PartialFormData | None — PartialFormData if cached, None otherwise.

Method PartialSaveStore.delete

Remove cached partial answers.

delete(form_id: str, session_id: str) -> bool

Parameter Type Default Description
form_id str Form identifier.
session_id str Session identifier.

Returns: bool — True if the key existed (and was deleted), False if no entry was cached or Redis is unavailable.

Method PartialSaveStore.remove_keys

Drop answer keys (cascade_clear) and refresh the TTL like save().

remove_keys(form_id: str, session_id: str, keys: Iterable[str]) -> PartialFormData | None

Parameter Type Default Description
form_id str Form identifier.
session_id str Session identifier.
keys Iterable[str] Answer keys (field_uid strings) to remove.

Returns: PartialFormData | None — The updated PartialFormData, or None when Redis is unavailable or no entry exists.

Method PartialSaveStore.close

Close the Redis connection if open.

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