Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Permanent Cache Bin

Security covered Maintenance fixes only 2,457 sites

This module allows you to use Drupal's caching system for external data without it being cleared during standard Drupal cache rebuilds. It offers sub-modules for Memcache and Redis support, and provides Drush commands and an administrative interface to manage these separate cache bins.

At times we need to cache some values which are not related to Drupal config or data but are coming from external systems and which don't really need to be deleted when clearing (rebuilding) Drupal cache.

This module provides a way to use Drupal cache but still keep it separate from drush cr.

Code to use this new backend in your bin (here stock is just for example):

  cache.stock:
    class: Drupal\Core\Cache\CacheBackendInterface
    tags:
      - { name: cache.bin, default_backend: cache.backend.permanent_database }
    factory: cache_factory:get
    arguments: [stock]

Update1: Memcache support is added through pcb_memcache sub-module.

Update 2: [18th Sep, 2018] Memcache version alpha7 is supported now in release 1.1, support for future versions of memcache will be added as soon as BLT supports them. Feel free to create an issue for support of beta version or new versions of memcache. There is no change done or required in main module (which uses database to store cache).

Update 2: Redis is supported now, thanks to szantog

Update 3: Use the 2.x branch for memcache 2.x, module is completely D9 ready now.

FAQ

1. How to clear permanent cache through drush?
To clear permanent cache drush pcbf [bin] (e.g. drush pcbf stock)

2. How to clear permanent cache programmatically?
\Drupal::service('cache.stock')->deleteAllPermanent();

3. How to clear permanent cache through admin?
For each cache bin using pcb, there will be a button in Admin -> Development -> Performance page (admin/config/development/performance). Use them to clear cache for specific bins through Admin UI.

4. Will cache tags and cache expiration work?
Yes, everything works as is. Only difference is when we use drush cr or try to delete all cache entries.

5. How to know which cache bins are using permanent cache?
drush pcb-list

6. How to flush cache for all bins using permanent cache?
drush pcb-flush-all

--------------------

Drupal 10–11 PHP >=8.1.0

Ask your assistant about Permanent Cache Bin

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

2 tracked projects depend on this one

Activity

Tracked releases
3
Tracked since
Aug 2024
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core PHP Release date
4.0.0 Stable 10–11 PHP >=8.1.0 Sep 25, 2024
4.0.x-dev Dev 10–11 PHP >=8.1.0 Sep 23, 2024
3.2.0 Stable 9–11 PHP >=8.1.0 Aug 10, 2024