feat: real flush() via ephpm_kv_flush_all#1
Open
luthermonson wants to merge 2 commits into
Open
Conversation
Backfills a working flush() now that ePHPm v0.1.2 ships the
ephpm_kv_flush_all(): bool SAPI function.
- 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.
- EphpmKvAdapter::doClear() previously hard-returned false. It now
falls back to ops->flush() when the adapter has no namespace
(matching how Symfony's RedisAdapter uses FLUSHDB without a
namespace). With a namespace it still returns false: flush_all
would nuke unrelated adapters, and we have no SCAN to delete
by prefix. Namespace versioning remains the recommended pattern
for namespaced clears.
Tests:
- Un-namespaced clear() returns true and removes every item.
- Namespaced clear() returns false and leaves both its own and
other adapters' keys intact.
- InMemoryKvOps::flush() clears values and deadlines.
The pre-existing test_unmarshall_failure_is_treated_as_miss test writes garbage bytes under a known cache key and asserts the adapter treats them as a miss. With igbinary present (as it is in CI), Symfony's DefaultMarshaller emits a PHP warning before returning false, and PHPUnit's failOnWarning fails the otherwise- passing assertion. CI on main has been red since the repo's first commit for exactly this reason. Catch only the unmarshall warning so a real bug elsewhere still surfaces.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Backfills a working
flush()now that ePHPm v0.1.2 ships theephpm_kv_flush_all(): boolSAPI function.KvOpsInterface,SapiKvOps,InMemoryKvOpsall gainflush().SapiKvOps::flush()callsephpm_kv_flush_all()behind afunction_existsguard so older runtimes returnfalseinstead of fataling;InMemoryKvOps::flush()clears its$values/$deadlinesarrays.EphpmKvAdapter::doClear()previously hard-returnedfalse. It now delegates to$this->ops->flush()when the adapter has no namespace, matching how Symfony'sRedisAdapterfalls back toFLUSHDBwhen no namespace is configured. With a namespace it still returnsfalse:flush_allwould nuke unrelated adapters, and we have no SCAN to delete by prefix - namespace versioning (new EphpmKvAdapter(''app.v2'')) remains the recommended pattern there.Tests
test_clear_flushes_when_adapter_has_no_namespace- un-namespacedclear()returnstrueand removes every item.test_clear_is_noop_when_adapter_has_namespace- namespacedclear()returnsfalseand the key survives.test_clear_with_namespace_does_not_disturb_other_namespaces- proves a namespacedclear()does not leak across into other adapters keys.InMemoryKvOpsTest::test_flush_clears_values_and_deadlines- flush wipes values AND deadlines (pttlreturns-2after).Incidental fix (required to make the suite green)
The pre-existing
test_unmarshall_failure_is_treated_as_misstest writes garbage bytes under a known cache key and asserts the adapter treats them as a miss. With igbinary present (as it is in CI), Symfony''sDefaultMarshalleremits a PHP warning before returning false, and PHPUnit''sfailOnWarningfails the otherwise-passing assertion. CI on main has been red since the repo''s first commit (2026-05-15) for exactly this reason. Caught only the unmarshall warning so a real bug elsewhere still surfaces.