Repository navigation
Conversation
Each entry is a PHP file (<?php return [...];) read with include: with OPcache, it is read from memory. Scalars and arrays are written as PHP code, other values serialized. The files are 0600 (an entry can hold secrets), written to a temporary file and renamed, and invalidated in OPcache. For entries written once and read on every request, such as byjg/config's cached container (~300 us less per web request in php-gluo than FileSystemCacheEngine). Not for values that change often. It runs the PSR-16 tests of every engine, plus its own.
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.
Summary
New PSR-16 engine
PhpFileCacheEngine: each entry is a PHP file (<?php return [...];) read withinclude, so with OPcache it is read from memory.0600(an entry can hold secrets, e.g. a cached configuration), written to a temporary file and renamed (never read half written), then invalidated in OPcache.For entries written once and read on every request, such as byjg/config's cached container: in php-gluo it removes ~300 us of file reads per web request compared with
FileSystemCacheEngine. Not for values that change often (each write recompiles the file; OPcache keeps the old one as wasted memory) — seedocs/class-php-file-cache-engine.md.Breaking changes
None.
Test plan
PhpFileCacheEngineTestextendsCachePSR16Test: the PSR-16 tests of every engine run against it (atomic and garbage-collector tests skipped: not supported), plus values round-trip (strings with quotes/NUL, ints, floats, nested arrays, objects, INF), 0600 permissions, replacement without temporary files left, a foreign file, a missing directory.