Documentation

CRM_Utils_Cache_SqlGroup
in package
implements CRM_Utils_Cache_Interface uses CRM_Utils_Cache_NaiveMultipleTrait

This caching provider stores all cached items as a "group" in the "civicrm_cache" table. The entire 'group' may be prefetched when instantiating the cache provider.

Table of Contents

Interfaces

CRM_Utils_Cache_Interface

Constants

DEFAULT_TTL  = 21600
TS_FMT  = 'Y-m-d H:i:s'

Properties

$componentID  : int
$expiresCache  : array<string|int, mixed>
In-memory cache to optimize redundant get()s.
$group  : string
Name of the cache group.
$table  : string
Table.
$valueCache  : array<string|int, mixed>
In-memory cache to optimize redundant get()s.

Methods

__construct()  : CRM_Utils_Cache_SqlGroup
Constructor.
clear()  : bool
Delete all values from the cache.
delete()  : bool
Delete a value from the cache.
deleteMultiple()  : bool
Deletes multiple cache items in a single operation.
flush()  : bool
Delete all values from the cache.
get()  : mixed
Get a value from the cache.
getFromFrontCache()  : mixed
getMultiple()  : iterable<string|int, mixed>
Obtains multiple cache items by their unique keys.
has()  : bool
Determines whether an item is present in the cache.
prefetch()  : mixed
set()  : bool
Set the value in the cache.
setMultiple()  : bool
Persists a set of key => value pairs in the cache, with an optional TTL.
where()  : mixed
assertIterable()  : mixed
reobjectify()  : object

Constants

DEFAULT_TTL

public mixed DEFAULT_TTL = 21600

TS_FMT

public mixed TS_FMT = 'Y-m-d H:i:s'

Properties

$expiresCache

In-memory cache to optimize redundant get()s.

protected array<string|int, mixed> $expiresCache

Note: expiresCache[$key]===NULL means cache-miss

$group

Name of the cache group.

protected string $group

$valueCache

In-memory cache to optimize redundant get()s.

protected array<string|int, mixed> $valueCache

Methods

__construct()

Constructor.

public __construct(array<string|int, mixed> $config) : CRM_Utils_Cache_SqlGroup
Parameters
$config : array<string|int, mixed>

An array of configuration params.

  • group: string
  • componentID: int
  • prefetch: bool, whether to preemptively read the entire cache group; default: TRUE
Tags
throws
RuntimeException
Return values
CRM_Utils_Cache_SqlGroup

clear()

Delete all values from the cache.

public clear() : bool

NOTE: flush() and clear() should be aliases. flush() is specified by Civi's traditional interface, and clear() is specified by PSR-16.

Return values
bool

deleteMultiple()

Deletes multiple cache items in a single operation.

public deleteMultiple(iterable<string|int, mixed> $keys) : bool
Parameters
$keys : iterable<string|int, mixed>

A list of string-based keys to be deleted.

Tags
throws
InvalidArgumentException

MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value.

Return values
bool

True if the items were successfully removed. False if there was an error.

flush()

Delete all values from the cache.

public flush() : bool

NOTE: flush() and clear() should be aliases. flush() is specified by Civi's traditional interface, and clear() is specified by PSR-16.

Return values
bool

getFromFrontCache()

public getFromFrontCache(string $key[, mixed $default = NULL ]) : mixed
Parameters
$key : string
$default : mixed = NULL

getMultiple()

Obtains multiple cache items by their unique keys.

public getMultiple(iterable<string|int, mixed> $keys[, mixed $default = NULL ]) : iterable<string|int, mixed>
Parameters
$keys : iterable<string|int, mixed>

A list of keys that can obtained in a single operation.

$default : mixed = NULL

Default value to return for keys that do not exist.

Tags
throws
InvalidArgumentException

MUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value.

Return values
iterable<string|int, mixed>

A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.

has()

Determines whether an item is present in the cache.

public has(mixed $key) : bool

NOTE: It is recommended that has() is only to be used for cache warming type purposes and not to be used within your live applications operations for get/set, as this method is subject to a race condition where your has() will return true and immediately after, another script can remove it making the state of your app out of date.

Parameters
$key : mixed

The cache item key.

Return values
bool

setMultiple()

Persists a set of key => value pairs in the cache, with an optional TTL.

public setMultiple(iterable<string|int, mixed> $values[, null|int|DateInterval $ttl = NULL ]) : bool
Parameters
$values : iterable<string|int, mixed>

A list of key => value pairs for a multiple-set operation.

$ttl : null|int|DateInterval = NULL

Optional. The TTL value of this item. If no value is sent and the driver supports TTL then the library may set a default value for it or let the driver take care of that.

Tags
throws
InvalidArgumentException

MUST be thrown if $values is neither an array nor a Traversable, or if any of the $values are not a legal value.

Return values
bool

True on success and false on failure.

where()

protected where([mixed $path = NULL ]) : mixed
Parameters
$path : mixed = NULL

reobjectify()

private reobjectify(mixed $value) : object
Parameters
$value : mixed
Return values
object

        
On this page

Search results