Hot answers tagged

3

As @Clive commented you need a node list cache tag. Put the slides and the cache tag when you invoke the template in the build array (not in a hook_theme(), this hook is only called when you install the module): class SliderBlock extends BlockBase { public function build() { $build = [ '#theme' => 'slider_block', '#slides' => ...


2

A) I highly recommend to measure your assumptions. Database might not be as bad as you think. The answer also depends on whether you ask for a sites that you control or whether you are writing a public module that has to play well with the whole ecosystem. The main difference between variable_set and cache_set is how important the value is. Cache is ...


2

As mentioned on the comments by @Clive and @leymannx, you need to use cache tags to do the job. The problem is with your current approach will be tricky since your nodes are being loaded by your theme hook. Would be much cleaner and Drupal-way of doing things if you refactor your code and make your nodes loaded by the block, so your theme hook can focus on ...


1

By any reason I do not really get the block rendering to respect my cache keys set wherever. It only respects set cache contexts so I create a custom cache context: In pw_basic.services.yml (pw_basic is the name ofthe module) cache_context.politician: class: Drupal\pw_basic\Cache\PoliticianCacheContext arguments: ['@current_route_match'] tags:...


1

// Memcache settings $settings['cache']['default'] = 'cache.backend.memcache'; $settings['memcache']['key_prefix'] = 'nfb_drupal_'; $settings['memcache']['memcached_servers'] = [ '127.0.0.1:11211' => 'default', ]; $settings['memcache']['bins'] = [ 'default' => 'default', // You can omit this config, because the "default" cluster will ...


Only top voted, non community-wiki answers of a minimum length are eligible