Documentation

CRM_Utils_Cache_NaiveMultipleTrait

Tags
copyright

CiviCRM LLC https://civicrm.org/licensing The traditional CRM_Utils_Cache_Interface did not support multiple-key operations. To get drop-in compliance with PSR-16, we use a naive adapter. An operation like getMultiple() just calls get() multiple times.

Ideally, these should be replaced with more performant/native versions.

Table of Contents

Methods

deleteMultiple()  : bool
Deletes multiple cache items in a single operation.
getMultiple()  : iterable<string|int, mixed>
Obtains multiple cache items by their unique keys.
setMultiple()  : bool
Persists a set of key => value pairs in the cache, with an optional TTL.
assertIterable()  : mixed

Methods

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.

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.

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.


        
On this page

Search results