Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enh: Introduce FindInstanceInterface - Part 1.b: TagDependency #6528

Draft
wants to merge 24 commits into
base: statable
Choose a base branch
from

Conversation

martin-rueegg
Copy link
Contributor

@martin-rueegg martin-rueegg commented Aug 19, 2023

Introduce FindInstanceInterface

Part 1.b Adding TagDependency to cached instances

FindInstanceInterface series:

Also see:

I've found a way do enable cache dependencies while not using a serializer ...

'runtimeCache' => [
	'class' => \yii\caching\ArrayCache::class,
	'serializer' => [
		static fn &($input) => $input,
		static fn &($input) => $input,
	],
],

TagDependencies only work if a serializer is used. Either the default PHP-internal serializer, or a user-provided. If serialization is disabled, they will not work.

Now since it would be unnecessary effort to serialize and unserialize runtime-cached items (which we all agree), serializing was disabled in common.php. This makes sense. However, the side effect of setting ['serializer' => false] is, that TagDependencies are disabled.

My suggested solution is, that we provide a user-defined serializer (an array of a serializing and unserializing function) which in both cases just return the value as-is. As such, the cache implementation thinks it does serializing, while actually, it doesn't.

Note: This trick only works for ArrayCache, not e.g. FileCache. So who ever decides to use a different Cache implementation for the runtime cache, needs to be aware of that.

* Sort profile fields on People directory filters

* Update CHANGELOG-DEV.md
@martin-rueegg martin-rueegg force-pushed the enh/new-find-interface-1-b branch 2 times, most recently from 7f42ed1 to 0612dfb Compare September 8, 2023 15:56
@martin-rueegg martin-rueegg changed the title Enh: Introduce FindInstanceInterface with methods to get (cached) instances - Part 1 b Enh: Introduce FindInstanceInterface - Part 1 b: TagDependency Sep 13, 2023
@martin-rueegg martin-rueegg changed the title Enh: Introduce FindInstanceInterface - Part 1 b: TagDependency Enh: Introduce FindInstanceInterface - Part 1.b: TagDependency Sep 13, 2023
@martin-rueegg martin-rueegg changed the title Enh: Introduce FindInstanceInterface - Part 1.b: TagDependency Enh: Introduce FindInstanceInterface - Part 1.b: TagDependency Sep 13, 2023
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.

None yet

2 participants