StorageInterface
in
Contract or guide for implement CacheHandler class.
Table of Contents
- clear() : bool
- Clear all caches by delete metadata and content files.
- delete() : bool
- Delete cache metadata and content file.
- get() : mixed
- Get cache content or return $default if cache not exists.
- getCurrentKey() : string|null
- Get current cache key.
- getCurrentMetadata() : array<string|int, mixed>|null
- Get current cache metadata assoc array.
- getTtl() : int
- Get cache TTL, default is 'default_ttl' value.
- has() : bool
- Check if cache exists and not expired, true if exists and not expired else false.
- set() : bool
- Save cache metadata and content to storage.
Methods
clear()
Clear all caches by delete metadata and content files.
public
clear() : bool
Return values
bool —Process result clear cache.
delete()
Delete cache metadata and content file.
public
delete(string $key) : bool
Parameters
- $key : string
-
Cache key (will be file name).
Return values
bool —Process result delete cache.
get()
Get cache content or return $default if cache not exists.
public
get(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
-
Cache key.
- $default : mixed = null
-
Default value if no cache.
Return values
mixed —Return cache content or $default.
getCurrentKey()
Get current cache key.
public
getCurrentKey() : string|null
Return values
string|null —Current cache key.
getCurrentMetadata()
Get current cache metadata assoc array.
public
getCurrentMetadata() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —Assoc array current cache metadata.
getTtl()
Get cache TTL, default is 'default_ttl' value.
public
getTtl() : int
Return values
int —Second TTL value.
has()
Check if cache exists and not expired, true if exists and not expired else false.
public
has(string $key) : bool
Parameters
- $key : string
-
Cache key.
Return values
bool —True if cache exists else false.
set()
Save cache metadata and content to storage.
public
set(string $key, mixed $value[, null|int|DateInterval $ttl = null ]) : bool
Parameters
- $key : string
-
Cache key (will be file name).
- $value : mixed
-
Cache content.
- $ttl : null|int|DateInterval = null
-
Seconds interval (int).
Return values
bool —Process result save cache.