ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v6:caching:memcached

The Memcached Caching Plugin

Description

This plugin enables caching using the Memcached library server. This library is usable by Linux clients

'' ADOdb\addins\cache\plugins\memcached\ADOCacheDefinitions ''

The ADOCachingDefinitions Class

class ADOCacheDefinitions
{
    /*
    * Debugging for cache
    */
    public bool $debug = false;
 
    /*
    * Service flag. Do not modify value
    */
    public string $service = 'memcached';
 
    /*
    * Default cache timeout
    */
    public int $cacheSeconds = 3600;
 
    /*
    * Add one or more servers, for use in distributed systems
    * @example array('192.168.0.78', '192.168.0.79', '192.168.0.80');
    */
    public array $memCacheHost = array();
 
    /*
    * Optionally add the server port if it differs from the default
    * @example 11211
    */
    public ?int $memCachePort = null;
 
    /*
    * Can now use the servers option for memcached, can specify
    * host, port and optionally weight for a group of controllers
    *
    * 'host'=>192.68.0.85','port'=>'11261','weight'=>66
    */
    public ?array $memCacheControllers = null;
 
    /*
    * Can optionally be used to set memcached server options
    */
    public ?array $memCacheOptions = null;
 
}

memcacheHosts

An array of hosts or IP addresses that provide the memcache service. All hosts must use the same port.

memcachePort

A port number for the memcache connection

memcacheCompress

A boolean that flags whether to use compression

memcacheControllers

See below for information on using this parameters. If defined, then the hosts and ports are not used.

memcacheOptions

Allows setting of options

/*
* Example Options
*/
$memcacheClass->memCacheOptions = array(Memcached::OPT_HASH=>Memcached::HASH_MURMUR);

Runtime Options

The memcached library supports use of the serverKey option, using the cacheDataObject

Example

$cls = new \stdClass;
 
$cls->ttl = 1800;
$cls->serverKey = 'tt-server';
 
$SQL = "SELECT * FROM departments";
 
$result = $db->cacheGetAll($SQL,false,$cls);
v6/caching/memcached.txt · Last modified: by 127.0.0.1