Example: Cache API
Same name in other branches
- 3.x modules/cache_example/cache_example.module \cache_example
- 4.0.x modules/cache_example/cache_example.module \cache_example
Outlines 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
Parent topics
File
-
cache_example/
cache_example.module, line 10
Functions
Title Sort descending | File name | Summary |
---|---|---|
cache_example_form_cache_clearing | cache_example/ |
Submit handler to demonstrate the various uses of cache_clear_all(). |
cache_example_form_create_expiring_item | cache_example/ |
Submit handler to create a new cache item with specified expiration. |
cache_example_form_expire_files | cache_example/ |
Submit handler that explicitly clears cache_example_files_count from cache. |
cache_example_menu | cache_example/ |
Implements hook_menu(). |
cache_example_page_form | cache_example/ |
Main page for cache_example. |
Classes
Title Sort descending | File name | Summary |
---|---|---|
CacheExampleTestCase | cache_example/ |
Functional tests for the Cache Example module. |