Allow rerouting CRM_Core_BAO_Cache::{set,get}Item(s) to PSR-16 drivers
authorTim Otten <totten@civicrm.org>
Mon, 21 Jan 2019 11:06:50 +0000 (03:06 -0800)
committerTim Otten <totten@civicrm.org>
Wed, 30 Jan 2019 02:53:11 +0000 (18:53 -0800)
commit5a302bbc2f3bd75b28401667f48966d65a4a0b36
treed616f3864c40b88dc8b958c8595794f0abc4ba1c
parentb8106826798885ea2b548b9d09ebe841322a7a0a
Allow rerouting CRM_Core_BAO_Cache::{set,get}Item(s) to PSR-16 drivers

Before
----------------------------------------

* Requests for `CRM_Core_BAO_Cache` (`setItem($data,$group,$path)`,
  `getItem($group,$path)`, `getItems($group)`, `deleteGroup($group,$path)`)
  are *always* served by two tiers: (1) an in-memory array (`static::$cache`) and (2)
  an SQL table.

After
----------------------------------------

* There is a config option `define('CIVICRM_BAO_CACHE_ADAPTER',
  'CRM_Core_BAO_Cache_Psr16');`.
    * When disabled (default), `CRM_Core_BAO_Cache` continues using the old code.
    * When enabled, `CRM_Core_BAO_Cache` changes behavior. Each `$group` is mapped to
      a PSR-16 object.

* The class/implementation for each `$group` depends on the configuration:
    * In a typical (non-Redis/non-Memcache) deployment, the implementation
      is `CRM_Utils_Cache_SqlGroup`, which has the same 2-tier structure
      (in-memory+SQL).
    * In Redis/Memcache deployment, the implementation combines
      `FastArrayDecorator` with `CRM_Utils_Cache_Redis` or
      `CRM_Utils_Cache_Memcache`.  This gives a similar 2-tier structure
      (e.g. in-memory+Redis).
CRM/Core/BAO/Cache.php
CRM/Core/BAO/Cache/Psr16.php [new file with mode: 0644]
CRM/Core/Config.php
templates/CRM/common/civicrm.settings.php.template