Provides a common API and a centralized place to manage caches.

Installs: 702

Dependents: 5

Suggesters: 1

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0


v3.0.0 2016-05-24 21:58 UTC

This package is auto-updated.

Last update: 2020-11-07 22:31:59 UTC


The Cache module (cache) provides a common API and a centralized place to manage caches.

The module comes with cache managers for the framework ICanBoogie.

Cache managers

Creating your own cache manager

You can use any kind of cache with the "cache" module, your manager only has to extends the CacheManagerBase class or implement the CacheManager interface.

The following properties must also be provided:

  • (string) title: Title of the cache. The title is translated within the cache.title scope.
  • (string) description: Description of the cache. The description is translated within the cache.description scope.
  • (string) group: Caches are displayed by groups. The group of the cache can be defined using this property. The group is translated within the cache.group scope.
  • (bool) state: Whether the cache is enabled.
  • (int|bool) size_limit: Size limit of the cache, or false if not applicable.
  • (int|bool) time_limit: Time limit of the entries in the cache, or false if not applicable.
  • (string|null) config_preview: A preview of the cache configuration, or null if not applicable.
  • (string) editor: The configuration editor, or null if not applicable.

Note: Because the config_preview and editor properties are seldom used, it is advised to use getters to return their values:


use ICanBoogie\Accessor\AccessorTrait;

abstract class CacheManagerAbstract implements Icybee\Modules\Cache\CacheManager
	use AccessorTrait;

	protected function get_config_preview()
		// …

	protected function get_editor()
		// …

Registering your cache manager

Cache managers are registered on the Icybee\Modules\Cache\CacheCollection::collect event. For instance, this is how the "views" module registers its cache manager using the hooks configuration:


// hooks.php

namespace Icybee\Modules\Views;

$hooks = Hooks::class . '::';

return [
	'events' => [
		'Icybee\Modules\Cache\CacheCollection::collect' => $hooks . 'on_cache_collection_collect',
		// ...
	// ...



Third parties may use the event of class Icybee\Modules\Cache\CacheCollection\CollectEvent to register their cache manager. The event is fired during the construct of the cache collection.

The following code is an example of how the icybee.views cache is added to the cache collection:


namespace Icybee\Modules\Views;

use Icybee\Modules\Cache\CacheCollection as CacheCollection;

class Hooks
	// …

	static public function on_cache_collection_collect(CacheCollection\CollectEvent $event, CacheCollection $collection)
		$event->collection['icybee.views'] = new ViewCacheManager;

	// …

Prototype methods


The get_caches getter is added to instances of the ICanBoogie\Application class, it returns the cache collection.


/* @var \ICanBoogie\Application $app */



Cache operations require the cache identifier to be defined as key of the operation. For instance, to clear the core.modules cache the operation POST /api/cache/core.modules/clear is used.


Clears the specified cache.


Configures the specified cache.


Disables the specified cache.


Returns the configuration editor.

The editor is obtained through the editor property of the cache.


Enables the specified cache.

The cache is cleared before it is enabled.


Returns the usage (memory, files) of the specified cache.

Event hooks


The caches of ICanBoogie are cleared when modules are activated.


The caches of ICanBoogie are cleared when modules are deactivated.


The package requires PHP 5.6 or later.


The recommended way to install this package is through Composer:

$ composer require icybee/module-cache

Cloning the repository

The package is available on GitHub, its repository can be cloned with the following command line:

$ git clone https://github.com/Icybee/module-cache.git


The package is documented as part of the Icybee CMS documentation. The documentation for the package and its dependencies can be generated with the make doc command. The documentation is generated in the docs directory using ApiGen. The package directory can later by cleaned with the make clean command.


The module is licensed under the New BSD License - See the LICENSE file for details.