Documentation

CacheHandler
in package
implements CacheHandlerInterface

Mediator for cache handler, also check are request allowed to cache.

Interfaces, Classes, Traits and Enums

CacheHandlerInterface

Table of Contents

$config  : array<string|int, mixed>
Mezzio specific configuration (mezzio_response_cache).
$ip  : string|null
Request IP address.
$isAllowCache  : bool
Flag/Result request allowed to cache (validate method).
$key  : string|null
String key cache.
$path  : string|null
Request URI path.
$storage  : StorageInterface
Cache storage handler instance.
__construct()  : self
Do nothing.
allowCache()  : bool
Get last validate process result.
clearCache()  : bool
Clear all available caches.
deleteCache()  : bool
Delete individual cache based $key parameter.
getContent()  : string|null
Get cache content from storage cache.
getExpireTime()  : int|null
Get cache expire time from cache storage.
getTtl()  : int
Get cache TTL from storage.
hasCache()  : bool
Check request already has cache or not.
setContent()  : bool
Set cache content to storage cache.
setIP()  : self
Set IP property for class.
setKey()  : self
Set key property for class, use for cache key.
setPath()  : self
Set path property for class.
validate()  : bool
Validate request is allowed to cache or not, based class properties and 'mezzio_response_cache' configurations.

Properties

$config

Mezzio specific configuration (mezzio_response_cache).

private array<string|int, mixed> $config

$isAllowCache

Flag/Result request allowed to cache (validate method).

private bool $isAllowCache = false

$path

Request URI path.

private string|null $path = null

Methods

__construct()

Do nothing.

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

Assoc array mezzio_response_cache configurations.

$storage : StorageInterface

Cache storage instance.

Return values
self

Class instance.

allowCache()

Get last validate process result.

public allowCache() : bool
Return values
bool

Validate process result.

clearCache()

Clear all available caches.

public clearCache() : bool
Return values
bool

Clear process result.

deleteCache()

Delete individual cache based $key parameter.

public deleteCache(string $key) : bool
Parameters
$key : string

Cache key to delete.

Return values
bool

Delete process result.

getContent()

Get cache content from storage cache.

public getContent([string|null $key = null ]) : string|null
Parameters
$key : string|null = null

String cache key.

Return values
string|null

String Cache content or null.

getExpireTime()

Get cache expire time from cache storage.

public getExpireTime([string|null $key = null ]) : int|null
Parameters
$key : string|null = null

String cache key.

Return values
int|null

Second expire time.

getTtl()

Get cache TTL from storage.

public getTtl() : int
Return values
int

Second TTL.

hasCache()

Check request already has cache or not.

public hasCache([string|null $key = null ]) : bool
Parameters
$key : string|null = null

String cache key.

Return values
bool

Check result.

setContent()

Set cache content to storage cache.

public setContent(mixed $content[, string|null $key = null ][, int|null $duration = null ]) : bool
Parameters
$content : mixed

Content to cache.

$key : string|null = null

String cache key.

$duration : int|null = null

Second duration cache.

Return values
bool

Set cache result.

setIP()

Set IP property for class.

public setIP(string $ip) : self
Parameters
$ip : string

String request IP address.

Return values
self

Class instance.

setKey()

Set key property for class, use for cache key.

public setKey(string|null $key) : self
Parameters
$key : string|null

String key for cache.

Return values
self

Class instance.

setPath()

Set path property for class.

public setPath(string $path) : self
Parameters
$path : string

String request URI path.

Return values
self

Class instance.

validate()

Validate request is allowed to cache or not, based class properties and 'mezzio_response_cache' configurations.

public validate() : bool
Return values
bool

Validation result.

Search results