Skip to content

feat: real flush() via ephpm_kv_flush_all - #1

Merged
luthermonson merged 1 commit into
mainfrom
feat/flush
Jun 26, 2026
Merged

luthermonson merged 1 commit into
mainfrom
feat/flush

Conversation

@luthermonson

Copy link
Copy Markdown
Contributor

What changed

Backfills a real flush() now that ePHPm v0.1.2 ships the ephpm_kv_flush_all(): bool SAPI function.

  • KV-ops trio — KvOpsInterface, SapiKvOps, InMemoryKvOps all gain flush(). SapiKvOps::flush() calls ephpm_kv_flush_all() behind a function_exists guard so older runtimes return false instead of fataling; InMemoryKvOps::flush() clears its $values/$deadlines arrays.
  • Framework wiring — EphpmStore::flush() previously hard-returned false (no key enumeration was possible). It now delegates to $this->ops->flush(), so Cache::flush() and php artisan cache:clear actually clear the store. It still returns false on pre-v0.1.2 runtimes via the guard.
  • Guarded for pre-v0.1.2 — on runtimes without the SAPI function, flush is a no-op returning false (recommended fallback: bump the cache prefix and let TTL age entries out).

Test

  • New test_flush_clears_all_entries (uses InMemoryKvOps): puts two keys, flushes, asserts both gone and flush() returned true.
  • Full suite: OK (28 tests, 75 assertions) under PHP 8.3. composer validate --strict passes.

Incidental fixes (required to make the suite run)

  • The service provider registered the cache driver in register(), calling the Cache facade before the framework's cache manager was bound — this threw Target class [cache] does not exist and broke the entire suite (CI on main is currently red for this reason). Moved the Cache::extend() call to boot(), the standard spot for driver extensions.
  • Fixed two pre-existing test bugs that surfaced once the suite executed: an assertion comparing serialized bytes to the logical value, and a call to the non-existent CacheManager::getDriver().

Do not merge yet.

Wire a working flush through the KV-ops trio into EphpmStore so
Cache::flush() and "php artisan cache:clear" actually drop entries.

- KvOpsInterface/SapiKvOps/InMemoryKvOps gain flush(): SapiKvOps calls
  ephpm_kv_flush_all() behind a function_exists guard (no-op false on
  pre-v0.1.2 runtimes); InMemoryKvOps clears its arrays.
- EphpmStore::flush() now delegates to ops->flush() instead of always
  returning false.
- Register the cache driver in boot() rather than register(): the cache
  manager is not yet bound during this provider's register() phase, so
  Cache::extend() there threw "Target class [cache] does not exist" and
  broke the whole test suite (and CI).
- Fix two pre-existing test bugs surfaced once the suite runs: a
  serialized-bytes assertion and a call to the non-existent
  CacheManager::getDriver().
@luthermonson
luthermonson merged commit 9cc1ec8 into main Jun 26, 2026
3 checks passed
@luthermonson
luthermonson deleted the feat/flush branch June 26, 2026 04:03
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