Skip to content

feat: add hash commands - #26

Merged
kacy merged 3 commits into
mainfrom
feat/hash-commands
Feb 6, 2026
Merged

feat: add hash commands#26
kacy merged 3 commits into
mainfrom
feat/hash-commands

Conversation

@kacy

@kacy kacy commented Feb 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • adds Value::Hash(HashMap<String, Bytes>) variant to the core type system
  • implements 10 hash commands: HSET, HGET, HGETALL, HDEL, HEXISTS, HLEN, HINCRBY, HKEYS, HVALS, HMGET
  • includes memory tracking with proper overhead estimation for hash entries
  • adds snapshot and recovery support for hash type persistence

Test plan

  • keyspace unit tests for all hash operations
  • command parsing tests for all 10 hash commands
  • type safety tests (hash operations on non-hash keys return WRONGTYPE)
  • auto-delete behavior when hash becomes empty via HDEL
  • HINCRBY edge cases (overflow, non-integer values)
  • all 450+ existing tests continue to pass
  • clippy passes with no warnings

Design considerations

  • hash memory overhead estimated as 64 bytes per entry + 48 bytes base, following the pattern established for other collection types
  • empty hashes are auto-deleted (matching redis behavior) to prevent memory leaks
  • HSET returns only the count of NEW fields (updates don't increment), matching redis semantics

kacy added 3 commits February 5, 2026 22:00
…N, HINCRBY, HKEYS, HVALS, HMGET commands

implements full redis-compatible hash operations:
- HSET: set one or more field-value pairs
- HGET: get a single field value
- HGETALL: retrieve all field-value pairs
- HDEL: delete one or more fields
- HEXISTS: check if a field exists
- HLEN: get the number of fields
- HINCRBY: atomically increment a field's integer value
- HKEYS: list all field names
- HVALS: list all values
- HMGET: get multiple field values at once

includes memory tracking, persistence (snapshot and recovery),
and comprehensive test coverage for all operations.
adds hash type to features list and includes usage examples
for HSET, HGET, HGETALL, and HINCRBY in the quickstart section.
@kacy
kacy merged commit dbcce19 into main Feb 6, 2026
5 checks passed
@kacy
kacy deleted the feat/hash-commands branch February 7, 2026 20:06
kacy added a commit that referenced this pull request Feb 11, 2026
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