Oihana PHP System

CacheableTrait

Provides caching functionality through a PSR-16 compliant cache implementation.

This trait enables caching support for classes by defining methods for interacting with a cache store as well as initialization of cache-related properties.

Table of Contents

Constants

CACHE  = 'cache'
The 'cache' parameter constant.
CACHEABLE  = 'cacheable'
The 'cacheable' parameter constant.

Properties

$cache  : CacheInterface|mixed|null
The PSR-16 cache reference.
$cacheable  : bool
Indicates if the instance use an internal PSR-16 c1ache.

Methods

clearCache()  : void
Clear the cache.
deleteCache()  : void
Delete a key/value in the cache.
getCache()  : mixed
Returns the registered value in the cache with a specific key.
hasCache()  : bool
Indicates if the key is registered in the cache.
isCacheable()  : bool
Indicates if the ressource can use the cache.
setCache()  : bool
Set a key/value in the cache.
setCacheMultiple()  : bool
Persists a set of key => value pairs in the cache, with an optional TTL.
initializeCache()  : void
Initialize the cache reference.
initializeCacheable()  : void
Initialize the cacheable property.

Constants

CACHE

The 'cache' parameter constant.

public mixed CACHE = 'cache'

CACHEABLE

The 'cacheable' parameter constant.

public mixed CACHEABLE = 'cacheable'

Properties

$cache

The PSR-16 cache reference.

public CacheInterface|mixed|null $cache = null

$cacheable

Indicates if the instance use an internal PSR-16 c1ache.

public bool $cacheable = true

Methods

deleteCache()

Delete a key/value in the cache.

public deleteCache(string $key) : void
Parameters
$key : string
Tags
throws
InvalidArgumentException

getCache()

Returns the registered value in the cache with a specific key.

public getCache(string $key) : mixed
Parameters
$key : string
Tags
throws
InvalidArgumentException

hasCache()

Indicates if the key is registered in the cache.

public hasCache(string|null $key) : bool
Parameters
$key : string|null
Tags
throws
InvalidArgumentException
Return values
bool

isCacheable()

Indicates if the ressource can use the cache.

public isCacheable([array<string|int, mixed> $init = [] ]) : bool
Parameters
$init : array<string|int, mixed> = []
Return values
bool

setCache()

Set a key/value in the cache.

public setCache(string $key, mixed $value) : bool
Parameters
$key : string
$value : mixed
Tags
throws
InvalidArgumentException
Return values
bool

setCacheMultiple()

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

public setCacheMultiple(array<string|int, mixed> $values[, int|null $ttl = null ]) : bool
Parameters
$values : array<string|int, mixed>
$ttl : int|null = null
Tags
throws
InvalidArgumentException
Return values
bool

initializeCache()

Initialize the cache reference.

protected initializeCache([array<string|int, mixed> $init = [] ][, Container|null $container = null ]) : void
Parameters
$init : array<string|int, mixed> = []
$container : Container|null = null
Tags
throws
DependencyException
throws
NotFoundException

initializeCacheable()

Initialize the cacheable property.

protected initializeCacheable([array<string|int, mixed> $init = [] ]) : void
Parameters
$init : array<string|int, mixed> = []

        
On this page

Search results