feat(task) #30 #31 #32 Options given by the input only, key validation, GetTask on_miss and SetTask expires_after - #33
Merged
Merged
Conversation
…n, GetTask on_miss and SetTask expires_after options Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
3 tasks
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.
Description
Fixes #30.
Fixes #31.
Fixes #32.
Grouped in one PR because the three changes modify the same tasks, tests and documentation pages.
#30: options given by the input only, key validation
AbstractCacheTask:adapterandkeyare no longer required at configuration level; they are required once merged with the input, ingetMergedOptions()(newgetRequiredOptions()method, overridden bySetTaskto addvalue). No more placeholders (key: '',value: ~) in the configurations.getMergedOptions()validates the key withCacheItem::validateKey(): Symfony adapters only validate the keys withassert()(The documentation states that invalid cache keys always throw an exception #28), so an empty key or a key with a reserved character was silently accepted in production. It now always throws aPsr\Cache\InvalidArgumentException.#31:
GetTaskon_missoptionoutput_null(default, current behaviour),skip(skip the item and send the input to the error outputs, asFilterTaskdoes: "cache-aside" pattern),fail(\UnexpectedValueException). Based onisHit(): a storednullvalue is always output.#32:
SetTaskexpires_afteroptionint(seconds, strictly positive) ornull(default: default lifetime of the adapter), passed toexpiresAfter(). Can be given by the input for a lifetime per item.Tests: options from the input only, required options on execution, invalid keys (empty, reserved character: they pass with
zend.assertions=-1), the threeon_missvalues (including a storednullwithskip),expires_afterfrom the options and from the input, invalidexpires_aftervalues. 60 tests, 78/78 lines.Documentation:
get_task.md,set_task.md(options, examples without placeholders, cache-aside and expiration examples, notes),adapter.md,index.md(custom tasks), both cookbooks (no placeholders,on_miss: skipinstead ofSkipEmptyTask).Checked with process-bundle-demo (with
php -d zend.assertions=-1), see the demo PR:demo.cache.set_getwithout placeholders: unchanged outputdemo.cache.get_on_miss:key1andkey2are computed and stored, the secondkey1is read from the cachedemo.cache.set_expires_after: the item is found right afterSetTask, and missing after a 2 seconds pausedemo.cache.set_invalid_key:Cache key "ABC/001" contains reserved characters "{}()/\@:".(stored silently before)Requirements
Breaking changes
''not overridden by the input, or a key with a reserved character) now always throws, also in production; it was silently accepted when assertions were disabled.adapter/key/valueis reported on execution instead of initialization.AbstractCacheTaskno longer getsadapterandkeyrequired at initialization;getMergedOptions()requires the options returned bygetRequiredOptions().Configurations with placeholders overridden by the input keep working.
on_missandexpires_afterdefault to the current behaviour.🤖 Generated with Claude Code