drupal 8/drupal 9 redis配置

Submitted by admin on Sat, 10/09/2021 - 13:38

settings.php配置

$settings['redis.connection']['interface'] = 'PhpRedis';
$settings['redis.connection']['host']      = '10.10.10.10';
$settings['redis.connection']['port']      = '6379';
$settings['redis.connection']['password'] = "your-redis-password";
$settings['cache_prefix'] = '1h_prd';
$settings['cache']['default'] = 'cache.backend.redis';
$settings['cache']['bins']['bootstrap']    = 'cache.backend.chainedfast';
$settings['cache']['bins']['discovery']    = 'cache.backend.chainedfast';
$settings['cache']['bins']['config']       = 'cache.backend.chainedfast';
$settings['cache']['bins']['container']       = 'cache.backend.redis';
$settings['cache']['bins']['data']       = 'cache.backend.redis';
$settings['cache']['bins']['boost']    = 'cache.backend.redis';
$settings['cache']['bins']['default']       = 'cache.backend.redis';
$settings['cache']['bins']['dynamic_page_cache']       = 'cache.backend.redis';
$settings['cache']['bins']['entity']       = 'cache.backend.redis';
$settings['cache']['bins']['menu']       = 'cache.backend.redis';
$settings['cache']['bins']['page']       = 'cache.backend.redis';
$settings['cache']['bins']['render']       = 'cache.backend.redis';
$settings['cache']['bins']['rest']       = 'cache.backend.redis';
$settings['cache']['bins']['signal']       = 'cache.backend.redis';
$settings['cache']['bins']['toolbar']       = 'cache.backend.redis';
$settings['cache']['bins']['ultimate_cron_logger']       = 'cache.backend.redis';

验证:

redis-cli
keys *
keys PREFIX:cache*
get "PREFIX:page:http://www.xxx.org.cn/node/567:html" tags
get "PREFIX:page:http://www.xxx.org.cn/node/567:html" data
del [cache-id]

drupal 8的网站,开启了page cache模块。

cache id: PREFIX:cache:page:http://example.com/[url]

通过执行redis-cli可以登录redis,执行

del [cache id]即可

参考

https://git.drupalcode.org/project/redis/-/blob/8.x-1.x/README.md https://docs.platform.sh/guides/drupal9/redis.html