RedisCache
in package
implements
CacheInterface
Redis cache provider, requires phpredis extension.
Table of Contents
Interfaces
- CacheInterface
- Cache interface
Properties
Methods
- __construct() : mixed
- Constructor
- clear() : bool
- Delete all cache items.
- delete() : bool
- Delete cache entry.
- fetch() : mixed|false
- Fetch entry.
- getRedis() : Redis
- Gets redis instance.
- getStats() : array<string|int, mixed>|null
- Return cache stats
- has() : bool
- Check if cache contains item
- save() : bool
- Save data into the cache.
Properties
$options
Driver options
protected
array<string|int, mixed>
$options
$redis
Redis instance
protected
mixed
$redis
@var Redis
Methods
__construct()
Constructor
public
__construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
- $options : array<string|int, mixed> = []
clear()
Delete all cache items.
public
clear() : bool
Return values
booldelete()
Delete cache entry.
public
delete(string $id) : bool
Parameters
- $id : string
-
cache id.
Return values
boolfetch()
Fetch entry.
public
fetch(string $id) : mixed|false
Parameters
- $id : string
Return values
mixed|false —The cached data or false
getRedis()
Gets redis instance.
public
getRedis() : Redis
Return values
RedisgetStats()
Return cache stats
public
getStats() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|nullhas()
Check if cache contains item
public
has(string $id) : bool
Parameters
- $id : string
Return values
boolsave()
Save data into the cache.
public
save(string $id, mixed $data[, int $lifeTime = 0 ]) : bool
Parameters
- $id : string
-
The cache id.
- $data : mixed
-
The cache entry/data.
- $lifeTime : int = 0
Return values
bool —true if data was successfully stored in the cache, false otherwise.