Skip to content

Implement handle store with TTL and expand #21

@dgenio

Description

@dgenio

Summary

Implement in-memory handle store with TTL eviction and structured expand queries.

HandleStore API

  • store(data, metadata, ttl_seconds=600) → Handle — unique handle_id, stores data + expiry
  • retrieve(handle_id) → (data, metadata) — raises HandleNotFound or HandleExpired
  • evict_expired() — remove all expired entries
  • Handle.data_shape: {"type": "list"|"dict"|"str", "count": N, "fields": [...], "size_bytes": N}

Expand queries — expand(handle_id, query) → Frame

Apply in order: filter → field selection → pagination → budget enforcement

  • {"offset": N, "limit": M} — pagination for list data
  • {"fields": ["a", "b"]} — field selection for list-of-dicts
  • {"filter": {"key": "value"}} — basic equality filter for list-of-dicts
  • Combinations work together: filter first, then select fields, then paginate
  • Non-applicable queries (e.g., pagination on a dict) are silently ignored
  • Result wrapped in a Frame with budgets applied

Acceptance criteria

  • Store + retrieve round-trip works
  • Expired handle raises HandleExpired
  • Missing handle raises HandleNotFound
  • evict_expired removes only expired entries
  • Expand pagination returns correct slice
  • Expand field selection returns only requested fields
  • Expand filter returns matching records only
  • Combined query: filter → fields → pagination

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions