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:reference:memcached [2016/01/13 02:31] – ↷ Links adapted because of a move operation mnewnhamv5:userguide:memcached [2017/04/18 10:26] – [Memcached Setup] add wikipedia link, formatting, minor rewording dregad
Line 1: Line 1:
 ====== Memcached Setup ====== ====== Memcached Setup ======
 +
 <WRAP tip> <WRAP tip>
-There are 2 pear modules for connection to a Memcached serverthe older [[https://pecl.php.net/package/memcache|PEAR Memcache library]] and the newer [[https://pecl.php.net/package/memcached|PEAR Memcached library]].  +There are 2 PEAR modules for connecting to a [[wp>Memcached]] serverthe [[https://pecl.php.net/package/memcache|Memcache]] library and the [[https://pecl.php.net/package/memcached|Memcached]] library
-  * Windows support is only available for the older Memcache library. +  * Windows support is only available for the //Memcache// library. 
-  * ADOdb has only been tested against the older library+  * //Memcache// should be used in PHP 5.x environments on UNIX platforms. 
 +  * //Memcached// should be used in PHP 7.x environments on UNIX platforms. 
 +  * If both libraries are available, //Memcache// will be used.
 </WRAP> </WRAP>
 +
 ===== Description ===== ===== Description =====
-This section describes connection to an already configured Memcache server. Information about installation and configuration of Memcached servers can be found [[https://memcached.org/|here]].+This section describes connecting to an already configured Memcache server. Information about installation and configuration of Memcached servers can be found [[https://memcached.org/|here]].
 ===== The Memcache Library ===== ===== The Memcache Library =====
  
Line 14: Line 18:
  
 $db = NewADOConnection($driver='mysqli'); $db = NewADOConnection($driver='mysqli');
 +
 /* /*
-* Enable memcache + * Enable memcache 
-*/+ */
 $db->memCache = true; $db->memCache = true;
 +
 /* /*
-* Add one or more servers, for use in distributed systems + * Add one or more servers, for use in distributed systems 
-*/ + */ 
-$db->memCacheHost = array('192.168.0.78', '192.168.0.79', '192.168.0.80'); +$db->memCacheHost = array('192.168.0.78', '192.168.0.79', '192.168.0.80'); 
 /* /*
-* Optionally add the server port if it differs from the default + * Optionally add the server port if it differs from the default 
-*/+ */
 $db->memCachePort = 11211; $db->memCachePort = 11211;
 +
 /* /*
-* 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 
-$db->memCacheCompress = false; +       parameter will be ignored when using the memcached library 
 + */ 
 +$db->memCacheCompress = false;
  
 /* /*
-* We connect to the database, not the memcache server + * We connect to the database, not the memcache server 
-*/+ */
 $db->Connect('localhost','mysql-user','mysql-password','employees'); $db->Connect('localhost','mysql-user','mysql-password','employees');
  
 /* /*
-* look for a cached query with a life of 2400 seconds + * look for a cached query with a life of 2400 seconds 
-*/+ */
 $sql = 'SELECT code,description FROM xref_table'; $sql = 'SELECT code,description FROM xref_table';
 $db->cacheExecute(2400,$sql); $db->cacheExecute(2400,$sql);
Line 44: Line 54:
 </code> </code>
 ===== Using Debug Mode  ===== ===== Using Debug Mode  =====
-The size of query results that can be cached by the memcached server is limited by server configuration. The default is quite small. If the query is too large, and [[v5:reference:debug|debugging]] is enabled, then an error is displayed.+The size of query results that can be cached by the memcached server is limited by server configuration. The default is quite small. If the query is too large, and [[v5:userguide:debug|debugging]] is enabled, then an error is displayed.
  
  
Line 50: Line 60:
   (this is a notice and not an error)   (this is a notice and not an error)
   -----<hr>   -----<hr>
-   + 
-  (mysqli): SELECT * FROM employees  +  (mysqli): SELECT * FROM employees 
-  +
   -----<hr>   -----<hr>
   Notice: MemcachePool::set(): Server 192.168.0.78 (tcp 11211, udp 0) failed with:   Notice: MemcachePool::set(): Server 192.168.0.78 (tcp 11211, udp 0) failed with:
Line 58: Line 68:
   (3) in C:\dev\github\mssqlnative-fixes\adodb-memcache.lib.inc.php on line 94   (3) in C:\dev\github\mssqlnative-fixes\adodb-memcache.lib.inc.php on line 94
   Failed to save data at the memcached server!   Failed to save data at the memcached server!
-  +
   Cache write error   Cache write error
-  +
   PHP Notice:  MemcachePool::set(): Server 192.168.0.78 (tcp 11211, udp 0) failed with:   PHP Notice:  MemcachePool::set(): Server 192.168.0.78 (tcp 11211, udp 0) failed with:
-  SERVER_ERROR object too large for cache (3) +  SERVER_ERROR object too large for cache (3)
   in C:\dev\github\mssqlnative-fixes\adodb-memcache.lib.inc.php on line 94   in C:\dev\github\mssqlnative-fixes\adodb-memcache.lib.inc.php on line 94
-  +
 ADOdb currently has no mechanism for splitting large queries into smaller chunks. ADOdb currently has no mechanism for splitting large queries into smaller chunks.
  
  
 {{tag>[memcached cache]}} {{tag>[memcached cache]}}
 +
v5/userguide/memcached.txt · Last modified: 2022/03/29 18:29 by dregad