October 2017
Intermediate to advanced
566 pages
14h 31m
English
Usually, the existing cache bins, particularly the default one, will be enough to store our own cache entries. However, there are times in which we need to create multiple entries for the same functionality, in which case it would help to have a special bin for that. So, let's see how that can be created.
It's quite easy because all we have to do is define a service:
cache.my_bin:
class: Drupal\Core\Cache\CacheBackendInterface
tags:
- { name: cache.bin }
factory: cache_factory:get
arguments: [my_bin]
The class used in this service definition is actually an interface. This is because we are using a factory to instantiate the service rather than the container directly. This means we don't know what class will be ...
Read now
Unlock full access