class Cache implements CacheInterface

Cache

Properties

protected Cache $driver Cache driver
protected string $cacheDir Cache directory
protected string $routeCacheFile Route cache file

Methods

__construct($cacheDir, $routerCacheFile, $driver = null, $status = false)

Constructor

string
getCacheDir()

Get cache dir

void
setStatus(boolean $status)

Set status true - enabled

boolean
getStatus()

Get status

boolean
isDiabled()

Return true if cache is status

Cache
getDriver()

Return cache driver

void
setDriver(Cache $driver)

Set cache driver

mixed|false
fetch(string $id)

Read item

bool
has(string $id)

Check if cache contains item

bool
save(string $id, mixed $data, int $lifeTime = 0)

Save cache item

bool
delete(string $id)

Delete cache item

array|null
getStats()

Return cache stats

void
clear()

Delete all cache items + views cache files and route cache

boolean
hasRouteCache()

Return true if route ceche file exist

bool
clearRouteCache()

Delete route cache items and route cache file

Details

at line 66
__construct($cacheDir, $routerCacheFile, $driver = null, $status = false)

Constructor

Parameters

$cacheDir
$routerCacheFile
$driver
$status

at line 81
string getCacheDir()

Get cache dir

Return Value

string

at line 92
void setStatus(boolean $status)

Set status true - enabled

Parameters

boolean $status

Return Value

void

at line 102
boolean getStatus()

Get status

Return Value

boolean

at line 112
boolean isDiabled()

Return true if cache is status

Return Value

boolean

at line 122
Cache getDriver()

Return cache driver

Return Value

Cache

at line 134
void setDriver(Cache $driver)

Set cache driver

Parameters

Cache $driver

Return Value

void

Exceptions

Exception

at line 149
mixed|false fetch(string $id)

Read item

Parameters

string $id

Return Value

mixed|false The cached data or false

at line 160
bool has(string $id)

Check if cache contains item

Parameters

string $id

Return Value

bool

at line 173
bool save(string $id, mixed $data, int $lifeTime = 0)

Save cache item

Parameters

string $id The cache id.
mixed $data The cache entry/data.
int $lifeTime In minutes

Return Value

bool true if data was successfully stored in the cache, false otherwise.

at line 184
bool delete(string $id)

Delete cache item

Parameters

string $id cache id.

Return Value

bool

at line 202
array|null getStats()

Return cache stats

Return Value

array|null

at line 212
void clear()

Delete all cache items + views cache files and route cache

Return Value

void

at line 227
boolean hasRouteCache()

Return true if route ceche file exist

Return Value

boolean

at line 237
bool clearRouteCache()

Delete route cache items and route cache file

Return Value

bool