Pionia Core

Service extends BaseService
in package
Uses Cacheable

Base Service for generic services

Table of Contents

Properties

$cachePrefix  : string
The cache prefix to use for caching.
$cacheTtl  : int
The cache ttl to use for caching.
$cacheInstance  : PioniaCache|null
The cache instance to use for caching.

Methods

cache()  : bool|mixed
Caches the value if the value is not null.
ClearByKeys()  : bool
Clear the cache.
deleteCache()  : bool
Delete the cache for the key.
getCache()  : mixed
getCacheInstance()  : PioniaCache|null
hasCache()  : bool
Check if the cache has the key.
setCache()  : bool
setCacheInstance()  : void
Set the cache instance to use for caching.
cleanCacheKey()  : string
getKeyName()  : string
Converts the key to snake case and appends the current class prefix if it does not exist.
logger()  : LoggerInterface|null

Properties

$cachePrefix

The cache prefix to use for caching.

public string $cachePrefix = __CLASS__

$cacheTtl

The cache ttl to use for caching.

public int $cacheTtl = 60

Defaults to 60 seconds.

$cacheInstance

The cache instance to use for caching.

private PioniaCache|null $cacheInstance = null

Methods

cache()

Caches the value if the value is not null.

public cache(string $key[, mixed $value = null ][, mixed $ttl = null ][, bool|null $exact = false ]) : bool|mixed
Parameters
$key : string

The key to cache

$value : mixed = null

The value to cache

$ttl : mixed = null

The time to live for the cache

$exact : bool|null = false

If passed, the key won't be parsed at all, it will be cached as is.

Return values
bool|mixed

ClearByKeys()

Clear the cache.

public ClearByKeys(array<string|int, mixed> $keys[, bool|null $exact = false ]) : bool
Parameters
$keys : array<string|int, mixed>

The keys to clear

$exact : bool|null = false

If passed, the keys won't be parsed at all

Return values
bool

deleteCache()

Delete the cache for the key.

public deleteCache(string $key[, bool $exact = false ]) : bool
Parameters
$key : string

The key to delete

$exact : bool = false

If passed, the key won't be parsed at all

Return values
bool

getCache()

public getCache( $key[, bool|null $exact = false ]) : mixed
Parameters
$key :
$exact : bool|null = false

hasCache()

Check if the cache has the key.

public hasCache( $key[, bool|null $exact = false ]) : bool

Will not throw an exception if the key is not set or the cache is not activated.

Parameters
$key :
$exact : bool|null = false
Return values
bool

setCache()

public setCache(string $key, mixed $value[, mixed $ttl = null ][, bool|null $exact = false ]) : bool
Parameters
$key : string
$value : mixed
$ttl : mixed = null
$exact : bool|null = false
Return values
bool

setCacheInstance()

Set the cache instance to use for caching.

public setCacheInstance(PioniaCache|null $cache) : void
Parameters
$cache : PioniaCache|null

cleanCacheKey()

private cleanCacheKey(string $key) : string
Parameters
$key : string
Return values
string

getKeyName()

Converts the key to snake case and appends the current class prefix if it does not exist.

private getKeyName(string $key) : string
Parameters
$key : string
Return values
string

logger()

private logger() : LoggerInterface|null
Return values
LoggerInterface|null

        
On this page

Search results