class CRM_Core_BAO_Cache_Psr16

Class CRM_Core_BAO_Cache_Psr16

This optional adapter to help phase-out CRM_Core_BAO_Cache.

In effect, it changes the default behavior of legacy cache-consumers (CRM_Core_BAO_Cache) so that they store in the best-available tier (Reds/Memcache or SQL or array) rather than being hard-coded to SQL.

It basically just calls "CRM_Utils_Cache::create()" for each $group and maps the getItem/setItem to get()/set().

Constants

TTL

Original BAO behavior did not do expiration. PSR-16 providers have diverse defaults. To provide some consistency, we'll pick a long(ish) TTL for everything that goes through the adapter.

Methods

getGroup(string $group)

No description

static object
getItem(string $group, string $path, int $componentID = NULL)

Retrieve an item from the DB cache.

static 
getItems(string $group, int $componentID = NULL)

Retrieve all items in a group.

static 
setItem(object $data, string $group, string $path, int $componentID = NULL)

Store an item in the DB cache.

static 
deleteGroup(string $group = NULL, string $path = NULL)

Delete all the cache elements that belong to a group OR delete the entire cache if group is not specified.

static 
clearDBCache()

Cleanup any caches that we've mapped.

static array
getLegacyGroups()

Get a list of known cache-groups

Details

at line 54
static protected CRM_Utils_Cache_Interface getGroup(string $group)

Parameters

string $group

Return Value

CRM_Utils_Cache_Interface

at line 89
static object getItem(string $group, string $path, int $componentID = NULL)

Retrieve an item from the DB cache.

Parameters

string $group (required) The group name of the item.
string $path (required) The path under which this item is stored.
int $componentID The optional component ID (so componenets can share the same name space).

Return Value

object The data if present in cache, else null

at line 111
static getItems(string $group, int $componentID = NULL)

Retrieve all items in a group.

Parameters

string $group (required) The group name of the item.
int $componentID The optional component ID (so componenets can share the same name space).

Exceptions

CRM_Core_Exception

at line 130
static setItem(object $data, string $group, string $path, int $componentID = NULL)

Store an item in the DB cache.

Parameters

object $data (required) A reference to the data that will be serialized and stored.
string $group (required) The group name of the item.
string $path (required) The path under which this item is stored.
int $componentID The optional component ID (so componenets can share the same name space).

at line 152
static deleteGroup(string $group = NULL, string $path = NULL)

Delete all the cache elements that belong to a group OR delete the entire cache if group is not specified.

Parameters

string $group The group name of the entries to be deleted.
string $path Path of the item that needs to be deleted.

at line 170
static clearDBCache()

Cleanup any caches that we've mapped.

Traditional SQL-backed caches are cleared as a matter of course during a system flush (by way of "TRUNCATE TABLE civicrm_cache"). This provides a spot where the adapter can

at line 182
static array getLegacyGroups()

Get a list of known cache-groups

Return Value

array