You are here

README.txt in Handy cache tags 8

CONTENTS OF THIS FILE
---------------------

 * Introduction
 * Requirements
 * Installation
 * Configuration
 * Maintainers


INTRODUCTION
------------

The Handy cache tags module provides some handy extra cache tags.

 * For a full description of the module visit:
   https://www.drupal.org/project/handy_cache_tags

 * To submit bug reports and feature suggestions, or to track changes visit:
   https://www.drupal.org/project/issues/handy_cache_tags


REQUIREMENTS
------------

This module requires no modules outside of Drupal core.


INSTALLATION
------------

 * Install the Handy cache tags module as you would normally install a
   contributed Drupal module. Visit https://www.drupal.org/node/1897420 for
   further information.


CONFIGURATION
-------------

The module provides the following cache tags for you to use:

```
handy_cache_tags:[entity_type]
handy_cache_tags:[entity_type]:[entity_bundle]
```

For example with nodes of the bundle "article" this would make the following
cache tags available:

```
handy_cache_tags:node
handy_cache_tags:node:article
```

The first would invalidate on any node (which by coincidence also is provided
through the "node_list" cache tag in core). The second would invalidate on any
node being created, updated, or deleted with the bundle article.

To generate these tags for your render array, you can use the following:

```$build['#cache'] = [
  'tags' => [
    // This one generates the bundle specific cache tag.
    \Drupal::service('handy_cache_tags.manager')
      ->getBundleTag('node', 'article'),
    // This one generates the entity type cache tag.
    \Drupal::service('handy_cache_tags.manager')
      ->getTag('node'),
  ],
];
```

If your render array deals with an entity, you can also use the following helper
functions:

```
// Get all tags for an entity:
\Drupal::service('handy_cache_tags.manager')
  ->getEntityTags(EntityInterface $entity);

// Get entity type tag from an entity:
\Drupal::service('handy_cache_tags.manager')
  ->getEntityTypeTagFromEntity(EntityInterface $entity);

// Get bundle tag from entity:
\Drupal::service('handy_cache_tags.manager')
  ->getBundleTagFromEntity(EntityInterface $entity);
```


MAINTAINERS
-----------

 * Eirik Morland (eiriksm) - https://www.drupal.org/u/eiriksm

Supporting organization:

 * Ny Media AS - https://www.drupal.org/ny-media-as

File

README.txt
View source
  1. CONTENTS OF THIS FILE
  2. ---------------------
  3. * Introduction
  4. * Requirements
  5. * Installation
  6. * Configuration
  7. * Maintainers
  8. INTRODUCTION
  9. ------------
  10. The Handy cache tags module provides some handy extra cache tags.
  11. * For a full description of the module visit:
  12. https://www.drupal.org/project/handy_cache_tags
  13. * To submit bug reports and feature suggestions, or to track changes visit:
  14. https://www.drupal.org/project/issues/handy_cache_tags
  15. REQUIREMENTS
  16. ------------
  17. This module requires no modules outside of Drupal core.
  18. INSTALLATION
  19. ------------
  20. * Install the Handy cache tags module as you would normally install a
  21. contributed Drupal module. Visit https://www.drupal.org/node/1897420 for
  22. further information.
  23. CONFIGURATION
  24. -------------
  25. The module provides the following cache tags for you to use:
  26. ```
  27. handy_cache_tags:[entity_type]
  28. handy_cache_tags:[entity_type]:[entity_bundle]
  29. ```
  30. For example with nodes of the bundle "article" this would make the following
  31. cache tags available:
  32. ```
  33. handy_cache_tags:node
  34. handy_cache_tags:node:article
  35. ```
  36. The first would invalidate on any node (which by coincidence also is provided
  37. through the "node_list" cache tag in core). The second would invalidate on any
  38. node being created, updated, or deleted with the bundle article.
  39. To generate these tags for your render array, you can use the following:
  40. ```$build['#cache'] = [
  41. 'tags' => [
  42. // This one generates the bundle specific cache tag.
  43. \Drupal::service('handy_cache_tags.manager')
  44. ->getBundleTag('node', 'article'),
  45. // This one generates the entity type cache tag.
  46. \Drupal::service('handy_cache_tags.manager')
  47. ->getTag('node'),
  48. ],
  49. ];
  50. ```
  51. If your render array deals with an entity, you can also use the following helper
  52. functions:
  53. ```
  54. // Get all tags for an entity:
  55. \Drupal::service('handy_cache_tags.manager')
  56. ->getEntityTags(EntityInterface $entity);
  57. // Get entity type tag from an entity:
  58. \Drupal::service('handy_cache_tags.manager')
  59. ->getEntityTypeTagFromEntity(EntityInterface $entity);
  60. // Get bundle tag from entity:
  61. \Drupal::service('handy_cache_tags.manager')
  62. ->getBundleTagFromEntity(EntityInterface $entity);
  63. ```
  64. MAINTAINERS
  65. -----------
  66. * Eirik Morland (eiriksm) - https://www.drupal.org/u/eiriksm
  67. Supporting organization:
  68. * Ny Media AS - https://www.drupal.org/ny-media-as