Skip to content

Comments

feat(cache): Add ability for optional custom prefix for Redis/Memcached cache keys#58334

Open
Earl0fPudding wants to merge 5 commits intonextcloud:masterfrom
Earl0fPudding:custom-cache-prefix
Open

feat(cache): Add ability for optional custom prefix for Redis/Memcached cache keys#58334
Earl0fPudding wants to merge 5 commits intonextcloud:masterfrom
Earl0fPudding:custom-cache-prefix

Conversation

@Earl0fPudding
Copy link

@Earl0fPudding Earl0fPudding commented Feb 13, 2026

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_customprefix for this.

Checklist

Signed-off-by: Martin <31348196+Earl0fPudding@users.noreply.github.com>
@Earl0fPudding Earl0fPudding requested a review from a team as a code owner February 13, 2026 15:30
@Earl0fPudding Earl0fPudding requested review from Altahrim, ArtificialOwl, come-nc and icewind1991 and removed request for a team February 13, 2026 15:30
@Earl0fPudding Earl0fPudding changed the title Add ability for optional custom prefix for Redis/Memcached cache keys feat(cache): Add ability for optional custom prefix for Redis/Memcached cache keys Feb 13, 2026
@Earl0fPudding
Copy link
Author

Backport to v32 would be perfect.

@kesselb
Copy link
Contributor

kesselb commented Feb 16, 2026

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>
@Earl0fPudding
Copy link
Author

Thank you for your feedback, @kesselb !
I've implemented it this way now.

@Earl0fPudding
Copy link
Author

PR for documentation: nextcloud/documentation#14080

@Earl0fPudding
Copy link
Author

/backport to stable32

….php

Signed-off-by: Martin <31348196+Earl0fPudding@users.noreply.github.com>
$instanceid = $config->getValue('instanceid');
$installedApps = implode(',', array_keys($versions)) . implode(',', array_values($versions));
$this->globalPrefix = hash('xxh128', $instanceid . $installedApps);
$this->globalPrefix = $customprefix . ($customprefix != '' ? '/' : '') . hash('xxh128', $instanceid . $installedApps);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->globalPrefix = $customprefix . ($customprefix != '' ? '/' : '') . hash('xxh128', $instanceid . $installedApps);
$this->globalPrefix = $customprefix . hash('xxh128', $instanceid . $installedApps);

I would prefer the above version to keep it simple.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Signed-off-by: Martin <31348196+Earl0fPudding@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow for (optional) Redis Key Prefix

2 participants