Skip to content

feat: GETRANGE, SETRANGE, SUBSTR string commands#259

Merged
kacy merged 3 commits intomainfrom
feat/string-getrange-setrange
Feb 24, 2026
Merged

feat: GETRANGE, SETRANGE, SUBSTR string commands#259
kacy merged 3 commits intomainfrom
feat/string-getrange-setrange

Conversation

@kacy
Copy link
Copy Markdown
Owner

@kacy kacy commented Feb 24, 2026

summary

full vertical slice for three string range commands:

  • GETRANGE key start end — substring extraction with negative index support (inclusive range, clamped to bounds)
  • SETRANGE key offset value — partial overwrite with zero-padding for gaps, TTL preservation
  • SUBSTR — aliases GETRANGE (same parser)

new AOF record type SetRange (TAG=32) for persistence. GETRANGE and SUBSTR are read-only so no AOF needed.

what was tested

  • cargo test -p emberkv-core — 64 string tests including 12 new getrange/setrange edge case tests
  • cargo test -p ember-protocol — 406 parser tests pass
  • cargo test -p ember-persistence — AOF round-trip tests pass
  • cargo test -p emberkv-cli — help ordering test passes
  • cargo build — clean compilation
  • 2 flaky cluster integration tests (cluster_delslots, cluster_redirect_followthrough) fail with connection reset — pre-existing, unrelated to this change

design considerations

  • GETRANGE returns Value::String(Bytes) via the existing ResponseTag::Get path — no new response tags needed
  • SETRANGE uses ResponseTag::LenResultOom since it can trigger OOM on zero-padding expansion
  • recovery replay mirrors the keyspace setrange logic (zero-pad + overlay) for correctness

kacy added 3 commits February 23, 2026 23:34
adds two new Keyspace methods:
- getrange: substring extraction with negative index support
- setrange: partial overwrite with zero-padding, TTL preservation
adds Command::GetRange and Command::SetRange variants with parse
functions. SUBSTR aliases to the same parser as GETRANGE.
completes the full vertical slice:
- shard dispatch for GetRange (read-only) and SetRange (write)
- AOF persistence for SETRANGE with TAG_SETRANGE=32
- recovery replay with zero-padding logic
- replication mapping
- sharded + concurrent connection handlers
- cluster slot checking
- CLI help entries for GETRANGE, SETRANGE, SUBSTR
@kacy kacy merged commit 448b60e into main Feb 24, 2026
6 of 7 checks passed
@kacy kacy deleted the feat/string-getrange-setrange branch February 24, 2026 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant