Cache
in package
uses
TraitData
FinalYes
Table of Contents
Constants
- DEFAULT_EXPIRE = 1800
- MEMCACHE_HOST = '127.0.0.1'
- MEMCACHE_PORT = 11211
- PREFIX_DEF = 'pdo:'
- PREFIX_ROWS = 'rows:'
- PREFIX_VAL = 'val:'
Properties
- $memCache : Memcached|null
Methods
- __construct() : mixed
- getData() : mixed
- Get data cache Used as a direct call on 35 places
- getDataInstance() : Data
- getResultOrSqlPrepared() : array<string|int, mixed>
- Prepared variant: cache key includes SQL + params For later use
- getValOrSQLPrepared() : mixed
- Prepared variant: cache key includes SQL + params
- setData() : void
- Set data cache Used as a direct call on 35 places
- getExpire() : int
- hashKey() : string
- logCacheError() : void
- makeCacheKey() : string
- Build a stable cache key for prepared queries.
- startMemCached() : Memcached
Constants
DEFAULT_EXPIRE
private
mixed
DEFAULT_EXPIRE
= 1800
MEMCACHE_HOST
private
mixed
MEMCACHE_HOST
= '127.0.0.1'
MEMCACHE_PORT
private
mixed
MEMCACHE_PORT
= 11211
PREFIX_DEF
private
mixed
PREFIX_DEF
= 'pdo:'
PREFIX_ROWS
private
mixed
PREFIX_ROWS
= 'rows:'
PREFIX_VAL
private
mixed
PREFIX_VAL
= 'val:'
Properties
$memCache
private
Memcached|null
$memCache
= null
Methods
__construct()
public
__construct() : mixed
getData()
Get data cache Used as a direct call on 35 places
public
getData(mixed $key) : mixed
Parameters
- $key : mixed
getDataInstance()
public
getDataInstance() : Data
Return values
DatagetResultOrSqlPrepared()
Prepared variant: cache key includes SQL + params For later use
public
getResultOrSqlPrepared(string $sql[, array<string|int, mixed> $params = [] ][, int $expire = self::DEFAULT_EXPIRE ]) : array<string|int, mixed>
Parameters
- $sql : string
- $params : array<string|int, mixed> = []
- $expire : int = self::DEFAULT_EXPIRE
Return values
array<string|int, mixed>getValOrSQLPrepared()
Prepared variant: cache key includes SQL + params
public
getValOrSQLPrepared(string $sql[, array<string|int, mixed> $params = [] ][, int $expire = self::DEFAULT_EXPIRE ]) : mixed
Parameters
- $sql : string
- $params : array<string|int, mixed> = []
- $expire : int = self::DEFAULT_EXPIRE
setData()
Set data cache Used as a direct call on 35 places
public
setData(mixed $key, mixed $data[, int $expire = self::DEFAULT_EXPIRE ]) : void
Parameters
- $key : mixed
- $data : mixed
- $expire : int = self::DEFAULT_EXPIRE
-
- 1800 seconds default
getExpire()
private
getExpire(int $expire) : int
Parameters
- $expire : int
Return values
inthashKey()
private
hashKey(mixed $key) : string
Parameters
- $key : mixed
Return values
stringlogCacheError()
private
logCacheError(string $method, Throwable $e) : void
Parameters
- $method : string
- $e : Throwable
makeCacheKey()
Build a stable cache key for prepared queries.
private
makeCacheKey(string $sql, array<string|int, mixed> $params) : string
Important: normalize SQL and sort params to keep key deterministic.
Parameters
- $sql : string
- $params : array<string|int, mixed>
Return values
stringstartMemCached()
private
startMemCached() : Memcached