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 [2021/01/25 02:30] mnewnhamv5:userguide:memcached [2021/01/25 03:49] – [Adding Weighted Server Groups] mnewnham
Line 62: Line 62:
  'host'=> The host name,  'host'=> The host name,
  'port'=> The port, defaults to 11211,  'port'=> The port, defaults to 11211,
- 'weight'=>percentag, up to 100,+ 'weight'=>percentage, up to 100,
 ); );
 </code> </code>
Line 82: Line 82:
  
 /* /*
- * Add the weighted servers+ * Add the weighted servers in $memCacheHosts. All other parameters are ignored.
  */  */
 $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.txt · Last modified: 2022/03/29 18:29 by dregad