Example: Cache API in Examples for Developers 8
Same name and namespace in other branches
- 7 cache_example/cache_example.module \cache_example
- 3.x modules/cache_example/cache_example.module \cache_example
Demonstrates how a module can use the Cache API.
Cache API allows us to cache data that is heavy to calculate. As this can significantly speed up the Drupal site, it is recommended to use cache mechanism when it is appropriate.
Cache in Drupal is very easy to use. This example will search entire Drupal folder and display all files. Since this operation includes filesystem it can take a while. This list will not change much on production websites, so we decide to cache it.
See also
\Drupal\Core\Cache\CacheBackendInterface
Parent topics
File
- cache_example/
cache_example.module, line 8 - Demonstrates how a module can use the Cache API.
Classes
Name | Location | Description |
---|---|---|
CacheExampleTest |
cache_example/ |
Tests for the cache_example module. |