ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:memcached

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
v5:userguide:memcached [2017/04/18 10:36] – Reorder sections dregadv5:userguide:memcached [2021/01/25 02:30] mnewnham
Line 5: Line 5:
  
 ===== The Memcache Library ===== ===== The Memcache Library =====
-There are 2 PEAR modules for connecting to a [[wp>Memcached]] server: the [[https://pecl.php.net/package/memcache|Memcache]] library and the [[https://pecl.php.net/package/memcached|Memcached]] library.+There are 2 distinct PEAR modules for connecting to a [[wp>Memcached]] server: the [[https://pecl.php.net/package/memcache|Memcache]] library and the [[https://pecl.php.net/package/memcached|Memcached]] library.
 <WRAP tip> <WRAP tip>
   * Windows support is only available for the //Memcache// library.   * Windows support is only available for the //Memcache// library.
Line 12: Line 12:
   * If both libraries are available, //Memcache// will be used.   * If both libraries are available, //Memcache// will be used.
 </WRAP> </WRAP>
 +===== Why can't I use the memcached library under Windows? ===== 
 +The memcached library is much more heavily featured, more modern and better maintained. The problem with it is not a problem with ADOdb, nor a problem with PHP. The PHP module is dependent on the 3rd party library **libmemcache**, which has no Windows support. Any Windows DLLs you might find floating around the web will __always__ be built on the memcache library.
  
  
Line 54: Line 55:
  
 </code> </code>
 +===== Adding Weighted Server Groups =====
 +From ADOdb version 5.22, the **memcached** library supports the use of **//Weighted server groups//**, in which a specific server can be forced to return a result a specific percentage of the time. If the feature is used, the total weighting of the server group must equal 100$.  To achieve this the configuration of the servers must be defined in a different way to the default. Each host is defined as an array:
 +
 +<code php>
 +array(
 + 'host'=> The host name,
 + 'port'=> The port, defaults to 11211,
 + 'weight'=> A percentag, up to 100,
 +);
 +</code>
 +
 +The host arrays are then combined together. In this example 86.91 serves 70% of requests and 86.92 serves 30%
 +<code php>
 +
 +$hosts = array(
 +    array('host'=>'192.168.86.91','port'=>'11211','weight'=>70)
 +    array('host'=>'192.168.86.92','port'=>'11211','weight'=>30)
 +    );
 +
 +$db = NewADOConnection($driver='mysqli');
 +
 +/*
 + * Enable memcache
 + */
 +$db->memCache = true;
 +
 +/*
 + * Add the weighted servers
 + */
 +$db->memCacheHost = $hosts
 + 
 +</code>
 +
 ===== Using Debug Mode  ===== ===== Using Debug Mode  =====
  
v5/userguide/memcached.txt · Last modified: 2022/03/29 18:29 by dregad