ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:learn_caching: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:learn_caching:memcached [2016/03/29 00:44] – [Memcached Setup] mnewnhamv5:userguide:learn_caching:memcached [2017/04/15 18:28] mnewnham
Line 1: Line 1:
- +<- v5:userguide:learn_caching:disk_caching|Disk Based Caching ^ v5:userguide:userguide_index|List Of Tutorials ^ v5:userguide:learn_caching:cache_ttl|Understanding Time-To-Live ->
-<- v5:userguide:learn_caching:disk_caching|Disk Based Caching ^ v5:userguide:userguide_index|List Of Tutorials ^ v5:userguide:learn_caching:adodb_coding|ADOdb Coding ->+
 ~~NOTOC~~ ~~NOTOC~~
-====== Memcached Setup ====== +<WRAP right tip box 300px> 
-Memcached provides a controlled, server based memory caching service. The server is reasonably easily configured and installed, but provides a sophisticated caching configuration. PHP support for the library is available through the PHP PEAR memcached library. For larger environments, an array of memcached hosts can be specified+== Learn More == 
-<WRAP tip> +[[https://memcached.org/|Configuring Memcached]] 
-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]].  +[[https://pecl.php.net/package/memcache|PEAR Memcache library]] 
-  * Windows support is only available for the older Memcache library. +[[https://pecl.php.net/package/memcached|PEAR Memcached library]]
-  * ADOdb has only been tested against the older library+
 </WRAP> </WRAP>
-===== Description ===== +====== Memcached Setup ====== 
-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]].+Memcached provides a controlled, server based memory caching serviceThe server is reasonably easily configured and installed, but provides a sophisticated caching configuration. PHP support for the library is available through the PHP PEAR memcache or PEAR memcached libraries. If both the memcache and memcached libraries are available, the memcache library will be used. 
 + 
 +Your platform and PHP version will be the primary decision factors between using memcache or memcached. In general, the following guidelines can be used. 
 + 
 +^ Platform  ^ PHP Version  ^ Library   ^ 
 +Windows   | 5.x, 7.x     | memcache 
 +| Unix      | 5.x          | memcache 
 +| Unix      | 7.x          | memcached | 
 + 
 +It's also worth noting that compression is not supported with memcached. If you need cache compression, the memcache library is recommended.
  
 +For larger environments, distributed Memcache hosts can be specified.
 +----------------------------------------------
 ===== Usage ===== ===== Usage =====
 <code php> <code php>
  
 $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');
- 
  
 </code> </code>
 +
v5/userguide/learn_caching/memcached.txt · Last modified: 2018/07/16 20:18 by peterdd