- Issue created by @Johan den Hollander
- First commit to issue fork.
- Merge request !25issue #3398797: get patch from #2765895 (closed issue) to apply here β (Open) created by pbonnefoi
- π«π·France pbonnefoi
@johan-den-hollander I opened an MR with the patch from #2765895 (with little improvements) I have other ideas, but need to find time to implement it.
I made this feature as an option with the following settings :
You can set flush_redis_on_drupal_flush_cache to TRUE to flush Redis cache when clearing all Drupal cache.
$settings['flush_redis_on_drupal_flush_cache'] = TRUE;
You can set flushdb and flushdb_async to TRUE to use the Redis native flushDB when clearing Drupal cache.
$settings['redis_flushdb'] = TRUE;
$settings['redis_flushdb_async'] = TRUE;You need to set a redis base properly to use this feature. By default, Redis gets cleared getting all keys using cache_prefix. This is not recommended on production as it could be an expensive task to clear all the keys.
- π³π±Netherlands Johan den Hollander
Thanks. Will give this a try.
We use the clearing of the Redis on drush cr on two identical sites.
However one of the sites is giving zend_memory_heap error when we do so.
When we first do a redis-flush and then a drush cr without the patch from this issue we have no errors.The other site has no problem clearing Redis via a drush cr.
I'm not sure if this error is only because of using this patch or that maybe we have some other issues like hosting configuration.
Althoug both of these sites are configured in the same way... - First commit to issue fork.
- π©πͺGermany Harlor Berlin
The redis client does not necessarily have databases. For instance the redis cluster cleint β¨ Implement initial RedisCluster client integration Needs review does not have databases.
How ever with redis_flushdb=FALSE one actually does not need the DB index anyway - So I would suggest to move the redis index/DB safety checks and the ->select into the flushdb block.
- π«π·France saadaouiyos
saadaouiyos β changed the visibility of the branch 3398797-drupal-cache-clear to hidden.
- πΈπ°Slovakia hideaway
There is a problem with the patch when prefix is an array and results into an error when logging messages. Correct version in the last else statement should be
'@prefix' => $p
:else { foreach ($prefix as $p) { $keys = $redis->keys('*' . $p . '*'); $redis->del($keys); Drupal::logger('redis')->info(t('Redis Keys deleted for prefix @prefix', ['@prefix' => $p])); Drupal::messenger()->addMessage(t('Redis Keys deleted for prefix @prefix', ['@prefix' => $p])); } }
As we don't use MR diff or patch files in our builds as they are dangerous, attaching a patch file to have working static patch.
- Status changed to RTBC
5 months ago 12:34pm 11 July 2024 - π©πͺGermany AntonΓn SlejΕ‘ka Hannover
We use the patch on multiple sites (in production). It works as expected.
- π³π±Netherlands renΓ© bakx Netherlands
This is a much needed feature and the patched got the job done!
It bit us in the back on a production env. Wondering why we where still seeing stale cache for objects set to never expire and no cache-tags to help them being evicted in other way.
And yes you are right, it's wrong and somewhat foolish to rely on cache clear to solve this problem, yet is worked perfectly till we moved that project to use redis for cache.
So yeah, please merge this and cut a new release :D
- π¬π§United Kingdom adam clarey
As mentioned above, this patch does not work with RedisCluser
PHP Fatal error: Uncaught Error: Call to undefined method RedisCluster::select() in /var/www/chat-dev/web/modules/contrib/redis/redis.module:61
Stack trace:
#0 [internal function]: redis_cache_flush() - π¨πSwitzerland berdir Switzerland
Contributions need to be merge requests.