I have a php written bot who updates several drupal content nodes every 15 minutes. It updates two existing numeric fields with current values. It is running so far, but:
I'm using the redis module and some redis settings to use the caching not within the db but in memory. The updated values don't get visible until I clear the cache using the admin web gui backend functions /under performance).
What I'd like to: Clear the right places in the cache via the external program.
Currently I'm trying this:
$this->drupaltagsinvalidator = \Drupal::service('cache_tags.invalidator');
$this->oNode = Node::load($nodeid);
$this->oNode->set($fieldname, $fieldvalue);
$this->oNode->revision = false;
$this->oNode->save();
$aCacheTags = $this->oNode->getCacheTags();
$this->drupaltagsinvalidator->invalidateTags($aCacheTags);
Those lines are the interesting ones in my class.
The cache tags look like
Clearing cache in Array ( [0] => node:7 )
when looking into my log.
What caching api should I call in addition to that one? Within the redis cache I don't find keys with exactly that name, but that might be normal I think. They have names like
":cachetags:node:7"
And just to be complete, my redis part in settings.php:
// Use Redis for caching.
$settings['redis.connection']['interface'] = 'PhpRedis';
$settings['redis.connection']['base'] = 1;
$settings['cache']['default'] = 'cache.backend.redis';
// Always set the fast backend for bootstrap, discover and config, otherwise
// this gets lost when redis is enabled.
$settings['cache']['bins']['bootstrap'] = 'cache.backend.chainedfast';
$settings['cache']['bins']['discovery'] = 'cache.backend.chainedfast';
$settings['cache']['bins']['config'] = 'cache.backend.chainedfast';
$settings['container_yamls'][] = 'modules/redis/example.services.yml';
Which really works well and fast until now.