Skip to content

[Feature] Chunked values: setValueChunked() / getValueChunked() #115

Description

@s2x

Problem

FDB enforces a hard limit of 100 kB per value (and 10 kB per key). Anything larger fails with value_too_large. Framework integrations we plan (Symfony/Laravel cache stores, session handlers, queue envelopes) regularly produce payloads above 100 kB (serialized objects, rendered HTML), so they need transparent chunking.

Proposal

Add chunking primitives to the library so adapters don't reinvent the wheel:

  • Transaction::setValueChunked(string $key, string $value, int $chunkSize = 100_000): void — writes $value split into $chunkSize-byte chunks at ordered sub-keys ($key + tuple suffix per chunk index), clears leftover chunks from a previous larger value in the same transaction (so reads never see stale tails).
  • Transaction::getValueChunked(string $key): ?string — reads all chunks in one range read and reassembles; returns null if the key doesn't exist.
  • Snapshot-read variants if applicable.

Limits / cap

  • Chunked write happens in a single transaction → atomicity is preserved, but the 10 000 000 B mutation budget applies: cap the assembled value at 8 MB (safe margin for key/tuple overhead, ~80 chunks) and throw a descriptive exception above it.
  • Reads use a range read — effectively bounded by the 5 s transaction limit only; the 8 MB cap keeps writes and reads symmetric.
  • Plain (non-chunked) set()/get() behavior unchanged.

Acceptance criteria

  • setValueChunked() / getValueChunked() on Transaction (+ snapshot variants if applicable)
  • Round-trip tests: value exactly at chunk boundary, value spanning multiple chunks, overwrite from larger to smaller value (stale chunk clearing), value > 8 MB rejected with clear error
  • Integration tests against the Docker cluster (values > 100 kB, multi-chunk)
  • Unit tests (chunk index packing via the tuple layer, no key > 10 kB)
  • docs/ + CHANGELOG entry

Context

Prep work for the planned Symfony bundle / Laravel package (cache store, session handler, queue transport) discussed in the team; those adapters will all need this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions