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

make keyPrefix default to $app->id for host-shared caches like Apc, Memcache #22

Open
dicrtarasov opened this issue Jun 9, 2019 · 4 comments
Labels
status:ready for adoption Feel free to implement this issue.

Comments

@dicrtarasov
Copy link

For shared caches, like APCu, Memcache, the defaut behaviour require to use keyPrefix, because of interpolability of hosting application, which share caches. So, defult configuration is not usabled.

I'm proposing set keyPrefix to \Yii::$app->id by default, so, the default configuration of \yii\cache\ApcCache, \yii\cache\MemCache become usable.

Q A
Yii version 2.0.20
PHP version 7.2
Operating system debian linux
@samdark
Copy link
Member

samdark commented Jun 9, 2019

That would cause backwards compatibility break. Won't be done in 2.x.

@samdark samdark closed this as completed Jun 9, 2019
@dicrtarasov
Copy link
Author

dicrtarasov commented Aug 24, 2019

@samdark
lets implements it in 3.x

$app->id is the best place for Cache::keyPrefix, and the default configuration is not suitable to work because of cache intersect conflicts in multiple web-applications.

So small code for big enhancements.
Settings Cache::keyPrefix defaults to Application::id rather then empty is the good reason.

Also, this will not "cause backwards compatibility break" in existing 2.x applications code, because the key prefix is not using in program logic never. Only empty keyPrefix may cause conflicts.

@samdark samdark transferred this issue from yiisoft/yii2 Aug 24, 2019
@samdark samdark reopened this Aug 24, 2019
@samdark
Copy link
Member

samdark commented Aug 24, 2019

Could be done in the default app config.

@samdark samdark added the status:ready for adoption Feel free to implement this issue. label Aug 24, 2019
@dicrtarasov
Copy link
Author

yes! for ex. as Requres::cookieValidationKey is generated in default config when installing :)
The difference is, the Cache::prefixKey is better in human-readable variant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready for adoption Feel free to implement this issue.
Projects
None yet
Development

No branches or pull requests

2 participants