Skip to content

Schema change: move Cache under Index #342

@zipdoki

Description

@zipdoki

Background

A Cache is meant to back an Index — Seek looks up start keys from the cache, and Scan continues from those start keys against the index. For this handoff to stay consistent, a cache must always exist paired with the index it backs.

Today the schema lets Cache be declared on its own, separate from any Index. That makes it easy for a cache to drift out of sync with the index it's supposed to back. We want to fix this at the schema level by making Cache a child of Index, so the two can never be defined independently.

There is also a related cleanup: Seek returns a set of start keys (not a single position), so the offset field on the Seek API no longer makes sense and should be removed first.

Task

  • Drop offset from the Seek API (request schema, server, clients) — done first
  • Move cache under index in the schema
  • Update docs and examples to the new schema shape
  • Write migration notes for users with existing top-level cache entries

Done When

  • The Seek API no longer accepts offset.
  • An index declares its cache inline, as shown below, and Seek/Scan share the same key layout end-to-end.
  • Existing tests pass; new tests cover the nested-cache path.
{
  "indices": [
    {
      "name": "permission_created_at_desc",
      "fields": [
        {
          "name": "permission",
          "order": "ASC"
        },
        {
          "name": "createdAt",
          "order": "DESC"
        }
      ],
      "desc": "createdAt desc index",
      "cache": {
        "dimension": [
          {
            "field": "permission",
            "values": [
              "others"
            ]
          }
        ],
        "limit": 100
      }
    }
  ]
}

Notes

  • Callers that used offset on Seek should switch to paging with the Scan cursor.
  • Existing top-level cache entries need to be moved under their owning index.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions