CacheRedis
in package
Class CacheRedis
Interact with Redis.
Table of Contents
- $logger : MonologWrapper
- $redis : Redis
- __construct() : mixed
- CacheMemcached constructor.
- clear() : bool
- Clear the Redis cache.
- get() : mixed
- Fetch a value from Redis. If the key does not exist, null is returned.
- init() : bool
- Initiate the memcached servers.
- set() : bool
- Store a value in Redis
- addServer() : bool
- Add a single server to redis.
Properties
$logger
protected
MonologWrapper
$logger
$redis
protected
Redis
$redis
Methods
__construct()
CacheMemcached constructor.
public
__construct(array<string|int, mixed> $servers, MonologWrapper $logger) : mixed
Parameters
- $servers : array<string|int, mixed>
- $logger : MonologWrapper
Return values
mixed —clear()
Clear the Redis cache.
public
clear() : bool
Return values
bool —get()
Fetch a value from Redis. If the key does not exist, null is returned.
public
get(string $key) : mixed
Parameters
- $key : string
-
Redis cache key.
Return values
mixed —init()
Initiate the memcached servers.
public
init(array<string|int, mixed> $servers) : bool
Parameters
- $servers : array<string|int, mixed>
Return values
bool —set()
Store a value in Redis
public
set(string $key, mixed $val, int $ttl) : bool
Parameters
- $key : string
-
Redis cache key.
- $val : mixed
-
Value to store in Redis.
- $ttl : int
-
Cache TTL.
Return values
bool —addServer()
Add a single server to redis.
protected
addServer([string $host = '127.0.0.1' ][, int $port = 6379 ][, string $password = '' ]) : bool
Parameters
- $host : string = '127.0.0.1'
- $port : int = 6379
- $password : string = ''