feat(cache): Add ability for optional custom prefix for Redis/Memcached cache keys#58334
feat(cache): Add ability for optional custom prefix for Redis/Memcached cache keys#58334Earl0fPudding wants to merge 3 commits intonextcloud:masterfrom
Conversation
Signed-off-by: Martin <31348196+Earl0fPudding@users.noreply.github.com>
|
Backport to v32 would be perfect. |
|
Thanks for your pr 👍 This should be implemented in https://github.com/nextcloud/server/blob/master/lib/private/Memcache/Factory.php |
Signed-off-by: Martin <31348196+Earl0fPudding@users.noreply.github.com>
Signed-off-by: Martin <31348196+Earl0fPudding@users.noreply.github.com>
|
Thank you for your feedback, @kesselb ! |
|
PR for documentation: nextcloud/documentation#14080 |
|
/backport to stable32 |
| } else { | ||
| // if not installed or in maintenance mode, we should distinguish between both states. | ||
| $versions['core:maintenance'] = $maintenanceMode ? '1' : '0'; | ||
| $customprefix = $config->getValue('memcache.customprefix', ''); |
There was a problem hiding this comment.
| $customprefix = $config->getValue('memcache.customprefix', ''); | |
| $customprefix = $config->getValue('memcache_customprefix', ''); |
New configuration options should follow https://docs.nextcloud.com/server/latest/developer_manual/basics/storage/configuration.html#naming-conventions. It's okay, that they don't align with the other memache. keys.
| $versions['core:maintenance'] = $maintenanceMode ? '1' : '0'; | ||
| $customprefix = $config->getValue('memcache.customprefix', ''); | ||
| // use the value of memcache.customprefix setting as prefix if set | ||
| if ($customprefix != '') { |
There was a problem hiding this comment.
That is a bad idea 🙈
Using the maintenance mode yes/no, server version and app version as global prefix ensures, that installing apps, updating nextcloud, etc automatically invalidates the old (after updating sometimes even invalid or unexpected) cache.
Remove the else block and prepend the custom prefix before the hash when assigning to globalPrefix.
| $config = Server::get(SystemConfig::class); | ||
| $customprefix = $config->getValue('memcache.customprefix', ''); | ||
| // use the value of memcache.customprefix setting as prefix if set | ||
| if ($customprefix != '') { |
There was a problem hiding this comment.
Same here ;)
Bonus points if you adjust $instanceid to use $config and not fetch SYstemConfig a second time from the container.
Summary
This adds the ability to use a custom prefix for Redis and Memcached keys. This is an optional variable.
One can use the variable setting
memcache.customprefixfor this.Checklist
3. to review, feature component)stable32)