Cache
in package
implements
CacheInterface
Cache
Table of Contents
Interfaces
- CacheInterface
- Cache interface
Constants
- APCU_DRIVER = 'apcu'
- DEFAULT_DRIVER = 'void'
- FILESYSTEM_DRIVER = 'filesystem'
- PREDIS_DRIVER = 'predis'
- REDIS_DRIVER = 'redis'
- VOID_DRIVER = 'void'
Properties
- $cacheDir : string
- Cache directory
- $driver : Cache
- Cache driver
- $drivers : array<string|int, mixed>
- Drivers list
- $routeCacheFile : string
- Route cache file
- $saveTime : int
- Default save time
Methods
- __construct() : mixed
- Constructor
- clear() : bool
- Delete all cache items + views cache files and route cache
- createDriver() : Cache|null
- Create cache driver
- createPath() : bool
- Create cache path.
- delete() : bool
- Delete cache item
- fetch() : mixed|false
- Read item
- getCacheDir() : string
- Get cache dir
- getDriver() : Cache
- Return cache driver
- getDriverName() : string|null
- Get cache driver name
- getStats() : array<string|int, mixed>|null
- Return cache stats
- getSupportedDrivers() : array<string|int, mixed>
- Get supported driver names.
- has() : bool
- Check if cache contains item
- isAvailable() : bool
- Return true if driver name is avaliable
- save() : bool
- Save cache item
- setDriver() : void
- Set cache driver
Constants
APCU_DRIVER
public
mixed
APCU_DRIVER
= 'apcu'
DEFAULT_DRIVER
public
mixed
DEFAULT_DRIVER
= 'void'
FILESYSTEM_DRIVER
public
mixed
FILESYSTEM_DRIVER
= 'filesystem'
PREDIS_DRIVER
public
mixed
PREDIS_DRIVER
= 'predis'
REDIS_DRIVER
public
mixed
REDIS_DRIVER
= 'redis'
VOID_DRIVER
public
mixed
VOID_DRIVER
= 'void'
Properties
$cacheDir
Cache directory
protected
string
$cacheDir
$driver
Cache driver
protected
Cache
$driver
$drivers
Drivers list
protected
array<string|int, mixed>
$drivers
= [Self::FILESYSTEM_DRIVER => 'Arikaim\\Core\\Cache\\Drivers\\FilesystemCache', Self::APCU_DRIVER => 'Arikaim\\Core\\Cache\\Drivers\\ApcuCache', Self::VOID_DRIVER => 'Arikaim\\Core\\Cache\\Drivers\\VoidCache', Self::REDIS_DRIVER => 'Arikaim\\Core\\Cache\\Drivers\\RedisCache', Self::PREDIS_DRIVER => 'Arikaim\\Core\\Cache\\Drivers\\PredisCache']
$routeCacheFile
Route cache file
protected
string
$routeCacheFile
$saveTime
Default save time
protected
int
$saveTime
Methods
__construct()
Constructor
public
__construct(string $cacheDir[, string $driverName = 'void' ][, int $saveTime = 7 ][, array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $cacheDir : string
- $driverName : string = 'void'
- $saveTime : int = 7
- $options : array<string|int, mixed> = []
clear()
Delete all cache items + views cache files and route cache
public
clear() : bool
Return values
boolcreateDriver()
Create cache driver
public
createDriver(string $name[, array<string|int, mixed> $options = [] ]) : Cache|null
Parameters
- $name : string
- $options : array<string|int, mixed> = []
Return values
Cache|nullcreatePath()
Create cache path.
public
createPath() : bool
Return values
booldelete()
Delete cache item
public
delete(string $id) : bool
Parameters
- $id : string
Return values
boolfetch()
Read item
public
fetch(string $id) : mixed|false
Parameters
- $id : string
Return values
mixed|falsegetCacheDir()
Get cache dir
public
getCacheDir() : string
Return values
stringgetDriver()
Return cache driver
public
getDriver() : Cache
Return values
CachegetDriverName()
Get cache driver name
public
getDriverName() : string|null
Return values
string|nullgetStats()
Return cache stats
public
getStats() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullgetSupportedDrivers()
Get supported driver names.
public
getSupportedDrivers() : array<string|int, mixed>
Return values
array<string|int, mixed>has()
Check if cache contains item
public
has(string $id) : bool
Parameters
- $id : string
Return values
boolisAvailable()
Return true if driver name is avaliable
public
isAvailable(string $driverName) : bool
Parameters
- $driverName : string
Return values
boolsave()
Save cache item
public
save(string $id, mixed $data[, int|null $lifeTime = 0 ]) : bool
Parameters
- $id : string
-
item id
- $data : mixed
-
item data
- $lifeTime : int|null = 0
-
lifetime in minutes
Return values
boolsetDriver()
Set cache driver
public
setDriver(Cache|string $driver[, array<string|int, mixed> $options = [] ]) : void
Parameters
- $driver : Cache|string
- $options : array<string|int, mixed> = []