Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

Modules defining cache bins

There is no need to provide schemas for their cache bins any more: no hook_schema implementations, no hook_update_N.

For successful uninstall you need to register your cache bin in modulename.services.yml like this:

 cache.bootstrap:
    class: Drupal\Core\Cache\CacheBackendInterface
    tags:
      - { name: cache.bin }
    factory_method: get
    factory_service: cache_factory
    arguments: [bootstrap]

Change the two occurences of bootstrap to the relevant bin name.

The automated uninstall even works for non-standard registration as long as the service is tagged as cache.bin and a factory_service / factory_method used with non-empty arguments. For other cases, a hook_uninstall needs to be written which figures out which cache backend stored this particular bin and call the removeBin method. This should almost never be necessary.

Cache backends

Cache backends implementing the new CacheBackendInterface need to take care of their own storage. See DatabaseBackend.php for an example. The only method on the interface to deal with bins is removeBin which is called when a module defining cache bins (as above) is uninstalled. Everything else is an internal affair to the backend.

Comments

gribnif’s picture

It seems that:

factory_method: get
factory_service: cache_factory

should be replaced with just:

factory: cache_factory:get

in current versions.