Documentation

AbstractStorage
in package

AbstractYes

Abstract implementation of a storage which saves and retrieves instances of `AbstractTemplate[]`.

It acts like a cache of data sources.

Table of Contents

Properties

$consumer  : mixed

Methods

__construct()  : mixed
C'tor.
getConsumer()  : mixed
Getter.
persist()  : void
Persist all templates to storage (e.g. save to filesystem, redis or database).
retrieve()  : array<string|int, AbstractTemplate>|false
Retrieve all templates from storage (e.g. request from filesystem, redis or database).
retrieveBy()  : array<string|int, AbstractTemplate>|false
Get a single template instance by criteria.
shouldInvalidate()  : bool
Check if the storage should be invalidated (e.g. after 24 hours). We highly recommend to return the database as source of truth by e.g. returning the result of `UPDATE` to avoid race conditions.

Properties

Methods

getConsumer()

Getter.

public getConsumer() : mixed
Tags
codeCoverageIgnore

persist()

Persist all templates to storage (e.g. save to filesystem, redis or database).

public abstract persist(array<string|int, AbstractTemplate$templates) : void
Parameters
$templates : array<string|int, AbstractTemplate>

retrieve()

Retrieve all templates from storage (e.g. request from filesystem, redis or database).

public abstract retrieve(bool|string $forceInvalidate) : array<string|int, AbstractTemplate>|false

Return false if data needs to be retrieved from data sources again.

Parameters
$forceInvalidate : bool|string

See ServiceCloudConsumer#retrieveBy parameters

Return values
array<string|int, AbstractTemplate>|false

Return false if the storage does not know about any templates so data sources are used to retrieve data. Afterwards, this is called again.

retrieveBy()

Get a single template instance by criteria.

public abstract retrieveBy(string $field, mixed $value, bool|string $forceInvalidate) : array<string|int, AbstractTemplate>|false

Predefined $field and $value schemas which you should receive to make it work with all our middlewares:

ResolveServiceTemplatesMiddleware
$field   = `identifier`
$value   = string

VersionsMiddleware
$field   = `versions`
$value   = [string (identifier), ...number]
Parameters
$field : string

Can be identifier, or whatever you want to implement to receive templates

$value : mixed
$forceInvalidate : bool|string

See ServiceCloudConsumer#retrieveBy parameters

Return values
array<string|int, AbstractTemplate>|false

Return false if the storage does not know about any templates so data sources are used to retrieve data. Afterwards, this is called again.

shouldInvalidate()

Check if the storage should be invalidated (e.g. after 24 hours). We highly recommend to return the database as source of truth by e.g. returning the result of `UPDATE` to avoid race conditions.

public abstract shouldInvalidate() : bool
Return values
bool

        
On this page

Search results