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
reference:memcached [2015/12/19 17:11] mnewnhamv5:userguide:memcached [2017/04/15 18:24] mnewnham
Line 1: Line 1:
 ====== Memcached Setup ====== ====== Memcached Setup ======
 <WRAP tip> <WRAP tip>
-There are 2 pear modules for connection to a Memcached server, the 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 Memcached server, the [[https://pecl.php.net/package/memcache|PEAR Memcache library]] and the [[https://pecl.php.net/package/memcached|PEAR 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 the memcache and memcached libraries are available, the memcache library 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 16:
  
 $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 52:
 </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 [[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 58:
   (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 66:
   (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. 
-   
-===== Using a memcached server with metacaching ===== 
  
-with the introduction of the [[dictionary:metacasing#the_metacache|MetaCache]] in ADOdb version 6, the performance can be enhanced further by using a memcached server to store data from the metacacheThis enhancement works best with small procedures that access multiple tables. The procedure flow is as follows:+ADOdb currently has no mechanism for splitting large queries into smaller chunks.
  
-  - A request is made for metadata 
-  - If the metadata is available from the local metacache, serve the request from there 
-  - Check the metacache on the memcached server. If available there, copy to the local metacache and serve the request. 
-  - If not available from the memcached server, request from the database, and store in both the local cache and on the memcached server for later use. 
  
-The functionality can be enabled by calling the following method ''$db->setMetaCachingByMemcached()''.+{{tag>[memcached cache]}}
  
-{{tag>[cache]}} 
v5/userguide/memcached.txt · Last modified: 2022/03/29 18:29 by dregad