This 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 Backdrop site, it is recommended to use cache mechanism when it is appropriate.

Cache in Backdrop is very easy to use. This example will search the entire Backdrop folder and display all files. Since this operation involves the filesystem, it can take a while. This list will not change much on production websites, so we decided to cache it.

See also





Parent topics


modules/examples/cache_example/cache_example.module, line 9
Hooks implementation for the Cache Example module.


Namesort descending Location Description
cache_example_form_cache_clearing modules/examples/cache_example/cache_example.module Submit handler to demonstrate the various methods for clearing cache.
cache_example_form_create_expiring_item modules/examples/cache_example/cache_example.module Submit handler to create a new cache item with specified expiration.
cache_example_form_expire_files modules/examples/cache_example/cache_example.module Submit handler that explicitly clears cache_example_files_count from cache.
cache_example_menu modules/examples/cache_example/cache_example.module Implements hook_menu().
cache_example_page_form modules/examples/cache_example/cache_example.module Main page for cache_example.


Namesort descending Location Description
CacheExampleTestCase modules/examples/cache_example/tests/cache_example.test Functional tests for the Cache Example module.