allow redis cache storage to delete only cached keys
since the same redis can be used for cache + session (or other stuff) only keys that match the -cache- should be used
Pull Request for Issue #43718
Summary of Changes
this code would delete ALL keys that aren't in a group regardless of being a cache or not e.g. deleting keys that handle session or any other stuff
if (strpos($key, $secret . self::CACHE_KEY . $group . '-') !== 0 && $mode !== 'group') {
static::$_redis->del($key);
the code
static::$_redis->keys('*' . self::CACHE_KEY . '*');
instead of
static::$_redis->keys('*');
makes sure redis cache ONLY handles cache keys
Testing Instructions
- setup a redis server
- define that server as a cache_handler + session_handler
- use the same server for redis_server_host + session_redis_server_host
- start caching stuff - and login on the first delete of a non group cache - you'll lose all of your sessions the easiest way to do that is to connect to redis with
redis-cli -h <host name>
HOST-NAME:PORT>monitor
and you'll see after a while these commands:
HOST-NAME:PORT>KEYS "*"
HOST-NAME:PORT>DEL <session-id 1>
HOST-NAME:PORT>DEL <session-id 2>
HOST-NAME:PORT>DEL <session-id 3>
....
Actual result BEFORE applying this Pull Request
seeing the
HOST-NAME:PORT>KEYS "*"
HOST-NAME:PORT>DEL <session-id 1>
HOST-NAME:PORT>DEL <session-id 2>
HOST-NAME:PORT>DEL <session-id 3>
....
Expected result AFTER applying this Pull Request
not seeing
HOST-NAME:PORT>KEYS "*"
HOST-NAME:PORT>DEL <session-id 1>
HOST-NAME:PORT>DEL <session-id 2>
HOST-NAME:PORT>DEL <session-id 3>
....
Link to documentations
Please select:
-
[ ] Documentation link for docs.joomla.org:
-
[x] No documentation changes for docs.joomla.org needed
-
[ ] Pull Request link for manual.joomla.org:
-
[x] No documentation changes for manual.joomla.org needed