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
v5:userguide:memcached [2021/01/25 02:33] – [Adding Weighted Server Groups] mnewnhamv5:userguide:memcached [2022/03/29 18:29] (current) – [Usage] compress also works with memcached now dregad
Line 38: Line 38:
 /* /*
  * Use 'true' to store the item compressed (uses zlib)  * Use 'true' to store the item compressed (uses zlib)
- * Note; Compression is only supported using the memcache library. This 
-       parameter will be ignored when using the memcached library 
  */  */
 $db->memCacheCompress = false; $db->memCacheCompress = false;
Line 56: Line 54:
 </code> </code>
 ===== Adding Weighted Server Groups ===== ===== 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:+ 
 +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 thisthe configuration of the servers must be defined in a different way to the default. Each host is defined as an array:
  
 <code php> <code php>
Line 70: Line 71:
  
 $hosts = array( $hosts = array(
-    array('host'=>'192.168.86.91','port'=>'11211','weight'=>70) +    array('host'=>'192.168.86.91','port'=>'11211','weight'=>70), 
-    array('host'=>'192.168.86.92','port'=>'11211','weight'=>30)+    array('host'=>'192.168.86.92','port'=>'11211','weight'=>30),
     );     );
  
Line 86: Line 87:
 $db->memCacheHost = $hosts $db->memCacheHost = $hosts
    
 +</code>
 +
 +===== Adding options to the memcached server =====
 +From ADOdb version 5.22, [[https://www.php.net/manual/en/memcached.setoption.php|server options]] can be set on the **Memcached** connection by use of the **memCacheOptions** array
 +
 +<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 in $memCacheHosts
 + */
 +$db->memCacheHost = $hosts;
 +
 +/*
 +* Set some options
 +*/
 +$db->memCacheOptions = array(Memcached::OPT_HASH=>Memcached::HASH_MURMUR);
 </code> </code>
  
v5/userguide/memcached.1611538387.txt.gz · Last modified: 2021/01/25 02:33 by mnewnham