===== The Redis Caching Plugin ====
~~NOTOC~~
==== Description ====
This plugin enables caching using a previously configured [[https://https://redis.io/|REDIS]] individual server. To connect to a cluster, use [[v6:caching:rediscluster]] .
'' ADOdb\addins\cache\plugins\redis\ADOCacheDefinitions ''
The system also supports features like AUTH and client side configurations.
==== Prerequisites ====
The Redis [[https://pecl.php.net/package/redis|PECL Package]]. The ADOdb extension works in conjuction with the package, as installed and configured [[https://github.com/phpredis/phpredis/|here]].
==== The ADOCachingDefinitions Class ====
class ADOCacheDefinitions
{
/*
* Debugging for cache
*/
public bool $debug = true;
/*
* Service flag. Do not modify value
*/
public string $serviceName = 'redis';
/*
* Service Name.
*/
public string $serviceDescription = 'REDIS';
/*
* The connection configuration
*/
public string $redisHost = '';
public int $redisPort = 6379,
public ?string $persistentId = null;
public int $retryInterval = 0;
public int $readTimeout = 0;
/*
* Sets the initial redis database
*/
public int $redisDatabase = 0;
/*
* Client options as available
*/
public array $redisClientOptions = array();
/*
* Are we adding a persistent connection
*/
public bool $redisPersistent = false;
/*
* Allow asyncronous deletion actions
*/
public bool $redisAsynchronous = false;
/*
* If used, must contain an array with at least one element
*/
public ?array $redisAuth = null;
/*
* If used, must contain a string which is the name of a function
* that returns an array of user,pass
*/
public string $redisAuthFunction = '';
}
=== redisHost ===
This **mandatory** item must contain the IP or host name of the REDIS server to which you are establishing a connection.
=== redisPort ===
If you are overriding the default port of 6379, please change it here
=== persistentId ==
If you a planning on establishing a persistent connection to the Redis server, set the key here. If you use a persistent connection, then the TTL set on the result becomes irrelevant as the data never expires.
=== retryInterval ===
To override the default retry time (in Milliseconds) set the value here.
== readTimeout ==
Th default timeout value for reading is 0, which creates a blocking interface to Redis server.
=== redisDatabase ===
if a non-default database is required, set the value here **0-9**
=== redisClientOptions ===
A key=>value pair array to set client type options
$redis = new ADOdb\addins\cache\plugins\redis\ADOCacheDefinitions;
$redis->redisClientOptions = array(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
=== redisPersistent===
A Boolean value telling the code to etablish a persistent connection to the database using the ID provided above.
=== redisAsynchronous ===
This is a boolean value (default false). If set to true, then the REDIS server will allow **Asynchronous Deletion** of records. Use with care because the ADOdb connection has no real way of dealing with the consequences of this.
=== redisAuth ===
If used, the ''$redisAuth'' value must be an array of at least one value, which will act as a userid. If 2 values are set, then the second value acts as a password.
=== redisAuthFunction ===
If this is used instead of ''$redisAuth'', then the value must be a string, which is the name of a function that returns an array of at least one value, which acts as a user id. If the function returns 2 values, the second is used as the password
function myPasswordProvider()
{
/*
* Do some code to obtain a user and pasword
*/
return array('username','password');
}
$redis = new ADOdb\addins\cache\plugins\redis\ADOCacheDefinitions;
$redis->redisAuthFunction = 'myPasswordProvider';