Skip to content

feat: use ePHPm v0.13 KV functions (hashes, MGET/MSET, GETDEL/GETEX, SCAN, SET IFEQ) - #4

Merged
luthermonson merged 1 commit into
mainfrom
feat/kv-v013
Oct 22, 2026
Merged

luthermonson merged 1 commit into
mainfrom
feat/kv-v013

Conversation

@luthermonson

Copy link
Copy Markdown
Contributor

Wires the Redis commands that ePHPm v0.13.0's new ephpm_kv_* functions can serve.

What changes

  • Hashes: HSET/HMSET, HGET, HMGET, HGETALL (flat reply, which Predis folds into an assoc array), HDEL, HEXISTS, HLEN, HKEYS, HVALS, HINCRBY, HSETNX.
  • Field TTLs: HEXPIRE gives a per-field reply (1 = set, -2 = no field, 2 = deleted when seconds is 0). HTTL, HPTTL and HPERSIST are also handled per field. HEXPIRE's NX/XX/GT/LT conditions raise CommandNotSupportedException and are never ignored, because they would need a non-atomic read-then-write. HPEXPIRE and the *AT variants stay unsupported.
  • Strings/keys: MGET, MSET, GETDEL, PERSIST, APPEND, STRLEN.
    • GETEX supports EX, PERSIST, no option, and PX when it is a whole number of seconds. Sub-second PX, EXAT and PXAT stay unsupported.
    • SCAN supports MATCH and COUNT. The reply is [cursor-as-string, keys], so Predis' Keyspace iterator works. The TYPE filter is unsupported. The README notes that in a cluster SCAN only sees this node's keyspace.
    • SET … IFEQ maps to ephpm_kv_set_if_eq. KEEPTTL is accepted together with IFEQ only.
  • TYPE returns hash through ephpm_kv_type when that function exists.

Compatibility

  • Feature detection: every command checks for its function(s) with function_exists. On an older ePHPm the command raises CommandNotSupportedException as it does today, and TYPE falls back to the exists-based answer.
  • Error message: the exception message now lists the commands the running ePHPm actually supports.
  • One exception changes: on an older ePHPm, SET … IFEQ used to throw InvalidArgumentException ("unknown SET modifier"). It now throws CommandNotSupportedException('SET IFEQ'), the same exception the other unsupported SET modifiers already throw.
  • Backends: a backend opts in to the new commands through the new ExtendedKvOpsInterface, so existing custom KvOpsInterface implementations still compile.
  • Test fake: InMemoryKvOps implements the new commands. new InMemoryKvOps([]) behaves like a runtime from before v0.13.

Tests

  • New KvConnectionExtendedTest runs every mapping through a real Predis client, so Predis does its own response parsing.
  • It also covers the fallback for each command (data provider), and a check that every EXTENDED_COMMANDS entry has a fallback case.
  • SapiKvOpsTest adds cases for supports() and for passing calls through to the stubs.
  • Ran locally with PHP 8.5.4 + PHPUnit 11.5: 121 tests OK.

….13 KV functions

Each command is feature-detected per ephpm_kv_* function; on an older
ePHPm it raises CommandNotSupportedException exactly as before. TYPE
reports 'hash' via ephpm_kv_type when available. Backends opt in through
the new ExtendedKvOpsInterface, so custom KvOpsInterface implementations
keep working unchanged.
@luthermonson
luthermonson merged commit fdcaf0d into main Oct 22, 2026
3 checks passed
@luthermonson
luthermonson deleted the feat/kv-v013 branch October 22, 2026 10:01
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