![]() ![]() To declare our cache, let's create the my. file in the directory of our my_module module.Ĭlass: Drupal\Core\Cache\CacheBackendInterfaceĪnd we declare our cache whose identifier will be my_cache. We can also use the default cache provided by Drupal 8 (the fault service), or declare and use our own cache, which will then have a dedicated table but which can also be managed separately, especially if we want to put this cache on a third party service such as Redis or Memcache. In order to remedy this small inconvenience, we will set up a specific cache for our business needs and use the Cache API. ![]() Once the hierarchical tree built, with all the included business data, satisfied, you can finally consult the fruit of your work. Imagine the need to build a hierarchical tree for a user, a tree based on a very prolific taxonomy. Context caches allow you to specify the criteria by which the cache of a page can vary (by user, by path, by language, etc.) while the max-age property can be used to define a maximum duration of cache validity.īut the purpose of this post is not to go into the details of this cache system, but rather to illustrate the use of the Cache API to set up its own cache for a specific use case. Tag caches allow you to tag content, pages, page elements with very precise tags allowing to easily and accurately invalidate all pages or page elements that have these caches tags. This cache system is based on three basic concepts: ![]() Drupal 8 has an automatic caching system activated by default that is truly revolutionary, which makes it possible to offer a cache for anonymous visitors and especially for authenticated users without any configuration. As we say in terms of computer programming, only two things are extremely complex: naming variables and invalidating the cache. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |