Documentation

CRM_Core_PrevNextCache_Redis
in package
implements CRM_Core_PrevNextCache_Interface

Class CRM_Core_PrevNextCache_Memory

Store the previous/next cache in a Redis set.

Each logical prev-next cache corresponds to three distinct items in Redis:

  • "{prefix}/{qfKey}/list" - Sorted set of entity_id, with all entities
  • "{prefix}/{qfkey}/sel" - Sorted set of entity_id, with only entities marked by user
  • "{prefix}/{qfkey}/data" - Hash mapping from entity_id to data
Tags
link
https://github.com/phpredis/phpredis

Table of Contents

Interfaces

CRM_Core_PrevNextCache_Interface
Interface CRM_Core_PrevNextCache_Interface

Constants

TTL  = 21600

Properties

$prefix  : string
$redis  : Redis

Methods

__construct()  : mixed
CRM_Core_PrevNextCache_Redis constructor.
cleanup()  : mixed
Remove items from prev/next cache no longer current
deleteItem()  : mixed
Delete an item from the prevnext cache table based on the entity.
fetch()  : array<string|int, mixed>
Fetch a list of contacts from the prev/next cache for displaying a search results page
fillWithArray()  : bool
Store the contents of an array in the cache.
fillWithSql()  : bool
Store the results of a SQL query in the cache.
getCount()  : int
Get count of matching rows.
getPositions()  : array<string|int, mixed>
Get the previous and next keys.
getSelection()  : array<string|int, mixed>|null
Get the selections.
getTTL()  : int
Get the time-to-live.
markSelection()  : mixed
Save checkbox selections.
initCacheKey()  : array<string|int, mixed>
Initialize any data-structures or timeouts for the cache-key.
key()  : string
Construct the full path to a cache item.

Constants

TTL

private mixed TTL = 21600

Properties

$prefix

protected string $prefix

$redis

protected Redis $redis

Methods

__construct()

CRM_Core_PrevNextCache_Redis constructor.

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

cleanup()

Remove items from prev/next cache no longer current

public cleanup() : mixed
Tags
inheritDoc

deleteItem()

Delete an item from the prevnext cache table based on the entity.

public deleteItem([mixed $id = NULL ][, mixed $cacheKey = NULL ]) : mixed
Parameters
$id : mixed = NULL
$cacheKey : mixed = NULL
Tags
throws
CRM_Core_Exception

fetch()

Fetch a list of contacts from the prev/next cache for displaying a search results page

public fetch(mixed $cacheKey, mixed $offset, mixed $rowCount) : array<string|int, mixed>
Parameters
$cacheKey : mixed
$offset : mixed
$rowCount : mixed
Return values
array<string|int, mixed>

List of contact IDs (entity_id1).

fillWithArray()

Store the contents of an array in the cache.

public fillWithArray(mixed $cacheKey, mixed $rows) : bool
Parameters
$cacheKey : mixed
$rows : mixed

A list of cache records. Each record should have keys:

  • entity_id1
  • data
Return values
bool

fillWithSql()

Store the results of a SQL query in the cache.

public fillWithSql(mixed $cacheKey, mixed $sql[, mixed $sqlParams = [] ]) : bool
Parameters
$cacheKey : mixed
$sql : mixed

A SQL query. The query MUST be a SELECT statement which yields the following columns (in order): cachekey, entity_id1, data

$sqlParams : mixed = []

An array of parameters to be used with $sql. Use the same interpolation format as CRM_Core_DAO (composeQuery/executeQuery). Ex: [1 => ['foo', 'String']]

Return values
bool

getCount()

Get count of matching rows.

public getCount(mixed $cacheKey) : int
Parameters
$cacheKey : mixed
Return values
int

getPositions()

Get the previous and next keys.

public getPositions(mixed $cacheKey, mixed $id1) : array<string|int, mixed>
Parameters
$cacheKey : mixed
$id1 : mixed
Return values
array<string|int, mixed>

List of neighbors. [ 'foundEntry' => 1, 'prev' => ['id1' => 123, 'data'=>'foo'], 'next' => ['id1' => 456, 'data'=>'foo'], ]

getSelection()

Get the selections.

public getSelection(mixed $cacheKey[, mixed $action = 'get' ]) : array<string|int, mixed>|null
Parameters
$cacheKey : mixed

Cache key.

$action : mixed = 'get'

One of the following:

  • 'get' - get only selection records
  • 'getall' - get all the records of the specified cache key
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>|null

getTTL()

Get the time-to-live.

public getTTL() : int

This is likely to be made configurable in future.

Return values
int

markSelection()

Save checkbox selections.

public markSelection(mixed $cacheKey, mixed $action[, mixed $ids = NULL ]) : mixed
Parameters
$cacheKey : mixed
$action : mixed

Ex: 'select', 'unselect'.

$ids : mixed = NULL

A list of contact IDs to (un)select. To unselect all contact IDs, use NULL.

initCacheKey()

Initialize any data-structures or timeouts for the cache-key.

private initCacheKey(mixed $cacheKey) : array<string|int, mixed>

This is non-destructive -- if data already exists, it's preserved.

Parameters
$cacheKey : mixed
Return values
array<string|int, mixed>

0 => string $allItemsCacheKey, 1 => string $dataItemsCacheKey, 2 => string $selectedItemsCacheKey, 3 => int $maxExistingScore

key()

Construct the full path to a cache item.

private key(string $cacheKey, string $item) : string
Parameters
$cacheKey : string

Identifier for this saved search. Ex: 'abcd1234abcd1234'.

$item : string

Ex: 'list', 'rel', 'data'.

Return values
string

Ex: 'dmaster/prevnext/abcd1234abcd1234/list'


        
On this page

Search results