Repository navigation
chore: absorb cache into packages/cache - #13899
Conversation
…adapter Add memcached adapter & tests
Added flush all functionality
Co-authored-by: Matej Bačo <[email protected]>
…to feat-add-ping-method
Added ping method to check cache connectivity
Hazelcast Adpater added, closes #3973
Added code analyzer
…eaker-0.4 cache: require circuit-breaker ^0.4
chore: stop committing package lock files
…ages Normalize recently absorbed packages
Bulk cache updates + fetch
…-reader fix(cache): retire the multiplexing reader while nothing is outstanding
…-377726 feat(cache): store values through a Codec, with Json and Igbinary implementations
…h-idle fix(cache): park the multiplexing reader through idle gaps instead of retiring per command
Appwrite now autoloads Utopia\Cache from packages/cache instead of vendor/, and the root replace entry satisfies the ^4 || ^5 constraint that the still-vendored database, domains and vcs packages declare.
# Conflicts: # composer.lock
|
| public function testEncodeWrapsDataAndTime(): void | ||
| { | ||
| $encoded = $this->envelope->encode('hello', 1700000000); | ||
| $this->assertSame('{"time":1700000000,"data":"hello"}', $encoded); |
There was a problem hiding this comment.
Tests pin JSON layout
These assertions require the exact JSON envelope string, including field order. A harmless serialization change would fail the tests even if cached values still round-trip and expire correctly. The assertion in CodecTest.php follows the same pattern. The repository requires tests to check observable behavior rather than mirror the implementation, so this requirement should be satisfied before merging.
Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cache/tests/EnvelopeTest.php
Line: 24
Comment:
**Tests pin JSON layout**
These assertions require the exact JSON envelope string, including field order. A harmless serialization change would fail the tests even if cached values still round-trip and expire correctly. The assertion in `CodecTest.php` follows the same pattern. The repository requires tests to check observable behavior rather than mirror the implementation, so this requirement should be satisfied before merging.
**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| public static function codecs(): iterable | ||
| { | ||
| yield 'json' => [new Json()]; | ||
| yield 'igbinary' => [new Igbinary()]; |
There was a problem hiding this comment.
Optional extension breaks unit tests
If a standalone install lacks ext-igbinary, this data provider constructs Igbinary and throws before the cases can run. The package only suggests that extension, so composer test fails on an otherwise supported install. Skip those cases when the extension is absent, or declare it as a test requirement.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cache/tests/CodecTest.php
Line: 21
Comment:
**Optional extension breaks unit tests**
If a standalone install lacks `ext-igbinary`, this data provider constructs `Igbinary` and throws before the cases can run. The package only suggests that extension, so `composer test` fails on an otherwise supported install. Skip those cases when the extension is absent, or declare it as a test requirement.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
# Conflicts: # composer.lock
Summary
This moves
utopia-php/cacheintopackages/cache, so Appwrite loads it directly. It follows the playbook inrfc/monorepo.md(wave 1 of #13828) and comes in three commits, plus a merge ofmain:Add 'packages/cache/' from commit '35fee421…': subtree import from the mirror with full history. The mirror head is the5.1.1release Appwrite already locks, and its tree matchespackages/cacheinutopia-php/monorepo(e8d3f32), so Appwrite runs the same code.chore(cache): mirror plumbing:mirror.ymlnow points here and the README banner is refreshed. There were no banned files to remove.refactor: load cache from packages/:replaceentries, drops theutopia-php/cache: ^5.1.0require line, and removes the package from the lock. The still-vendoreddatabase,domainsandvcsrequireutopia-php/cache: ^4.0 || ^5.0, andreplacenow satisfies them.src/Cache/*moves up tosrc/.tests/Cache/Unit/*,Base.phpandServices.phpmove up totests/;tests/Cache/E2Eandtests/Cache/Scopebecometests/E2Eandtests/Scope.tests/benchstays where it was, excluded from both tiers.Utopia\Testsnamespace (andUtopia\Tests\Unit,\E2E,\Scope) toUtopia\Cache\Tests, with a matchingautoload-deventry.Services::compose()now resolvesdocker-compose.ymlone level up.phpunit.xmlrunstestswithtests/E2Eandtests/benchexcluded for the unit suite.phpstan.neonused to include the monorepo root config, andvalidaterejects that, so it's now standalone at level max oversrcandtests. Aphpstan-baseline.neonholds 25 findings, since the monorepo analysed this package at level 5. They aremixedfrom the Memcached and Hazelcast server stats and theRedisClusternode addresses, values passed toEnvelope::encode()untyped, and casts of Redis replies in four e2e tests. The RFC's phase 8 burn-down list now includes them.rector.phpwith the monorepo root's sets. It skipsReadOnlyPropertyRectorandRemoveDefaultValueFromAssignedPropertyRector, which would otherwise rewrite property declarations inAdapter/Redis.phpandAdapter/Redis/Multiplexing.php. Absorbing only moves code, so those declarations stay exactly as they were released.src/is byte-for-byte the release apart from the path move and Pint formatting (empty{}bodies andfn (spacing). Pint also reorders a few imports in the tests.git diff -wagainst the import shows only brace placement.Nothing to hoist: the package's third-party requirement is
ext-json, which the root already requires.circuit-breaker,poolsandtelemetryare already inpackages/.swoole/ide-helperstays in itsrequire-devfor PHPStan.Net: +8,368 / −63 across the three commits, nearly all of it the imported package. The root side is +5 / −63 (
composer.json,composer.lock,rfc/monorepo.md).Open issues and PRs on the mirror, for triage after merge
mirror-redirectwill close anything new; these predate the freeze:fix: update filemtime when calling load() in the FileSystem adapter(sliding TTL forFilesystem): the only one with a live idea. It touchessrc/Cache/Adapter/Filesystem.phpand predates the move, so porting it means re-applying it topackages/cache/src/Adapter/Filesystem.php. It is also a behaviour change (read-extends-TTL), so it needs a decision on its own.Feat 3974 varnish cache adapter(2023) and Feat mcrouter utopia-php/cache#31Feat mcrouter(2023): new adapters built against the old layout with PHP 8.0 Dockerfiles. Propose closing them with a pointer here.Add static code analysis and including CI/CD checkand Add code formatter and CI/CD linter utopia-php/cache#46Add code formatter and CI/CD linter: both done here (Pint, PHPStan level max and Rector throughbin/monorepo check). Close.MOVEDerrors):RedisClusterandShardingadapters exist now. Close unless the reporter's self-hosted setup still needs Appwrite-side wiring.There is also utopia-php/monorepo#279 (
perf(cache): reuse the decoded envelope while the stored string is unchanged), open and not merged. If it's still wanted it has to be re-opened here againstpackages/cache.Validation
bin/monorepo validate: all packages validbin/monorepo check cache: Rector, Pint and PHPStan level max (with baseline) passbin/monorepo test cache: on the macOS host the unit tier reaches 108 tests and 6 fail, because the host PHP has noigbinaryand six tests exercise theIgbinarycodec. So I ran the tiers separately:appwrite/appwrite:2.3.0(hasigbinary,redisandswoolelike the CIunitjob):vendor/bin/phpunit --testsuite packages --filter 'Utopia\\Cache', 114 tests / 255 assertions, 2 skippeddocker-compose.yml(unique compose project, torn down afterwards): 116 tests / 448 assertions in all. The Redis, RedisCluster, Sharding, leasable and four multiplexing suites ran in the same image on the host network, because host Swoole 6 on macOS segfaults in the multiplexing suites (this is a host problem, not this change). Memcached and Hazelcast ran on the host, because the image has nomemcachedextensionUtopia\Cache\Cacheresolves topackages/cache/src/Cache.phpfrom the root autoloaderphpstan.neon) onDatabase/Factory.php,Auth/Validator/PasswordPwned{,/HIBP,/Appwrite}.php,Auth/OIDC/Jwks.php,Platform/Tasks/{Doctor,Specs}.phpandPlatform/Workers/Deletes.php: no errorstests/unit/Auth,Vcs/FactoryTest,Autogravity/DetectorTest, theNotifications/Webhooksworkers and the messaging adapters): 214 pass.Auth/KeyTest::testDecodeneeds_APP_OPENSSL_KEY_V1, which the container sets; it passes with the variable setcomposer update --lockafter mergingmain: the lock diff againstmaindrops onlyutopia-php/cache 5.1.1composer validate --no-check-publish: valid. The only warning was already there (utopia-php/platformpinned exactly)bin/monorepo split cache --dry-run:b6f27f22, which fast-forwards from the mirror head35fee421git diff --checkMerge and follow-up
Merge with a merge commit. A squash drops the
git-subtree-*annotation and orphans the package from its mirror.The
utopia-php/cachemirror already has the canonicalmainruleset (id20338832), with the split app as an always-bypass actor, so the absorb ran with--skip-ruleset.After merge:
Splitpushes toutopia-php/cache.packages/cachefromutopia-php/monorepo.🤖 Generated with Claude Code