v5:userguide:memcached
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
v5:userguide:memcached [2016/01/17 03:39] – ↷ Page moved from v5:reference:memcached to v5:userguide:memcached mnewnham | v5:userguide:memcached [2021/01/25 02:30] – mnewnham | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Memcached Setup ====== | ====== Memcached Setup ====== | ||
- | <WRAP tip> | + | |
- | There are 2 pear modules for connection to a Memcached server, the older [[https:// | + | |
- | * Windows support is only available for the older Memcache library. | + | |
- | * ADOdb has only been tested against the older library | + | |
- | </ | + | |
===== Description ===== | ===== Description ===== | ||
- | This section describes | + | This section describes |
===== The Memcache Library ===== | ===== The Memcache Library ===== | ||
+ | There are 2 distinct PEAR modules for connecting to a [[wp> | ||
+ | <WRAP tip> | ||
+ | * Windows support is only available for the // | ||
+ | * // | ||
+ | * // | ||
+ | * If both libraries are available, // | ||
+ | </ | ||
+ | ===== Why can't I use the memcached library under Windows? ===== | ||
+ | The memcached library is much more heavily featured, more modern and better maintained. The problem with it is not a problem with ADOdb, nor a problem with PHP. The PHP module is dependent on the 3rd party library **libmemcache**, | ||
Line 14: | Line 20: | ||
$db = NewADOConnection($driver=' | $db = NewADOConnection($driver=' | ||
+ | |||
/* | /* | ||
- | * Enable memcache | + | * Enable memcache |
- | */ | + | */ |
$db-> | $db-> | ||
+ | |||
/* | /* | ||
- | * Add one or more servers, for use in distributed systems | + | * Add one or more servers, for use in distributed systems |
- | */ | + | */ |
- | $db-> | + | $db-> |
/* | /* | ||
- | * Optionally add the server port if it differs from the default | + | * Optionally add the server port if it differs from the default |
- | */ | + | */ |
$db-> | $db-> | ||
+ | |||
/* | /* | ||
- | * Use ' | + | * Use ' |
- | */ | + | * Note; Compression is only supported using the memcache library. This |
- | $db-> | + | |
+ | */ | ||
+ | $db-> | ||
/* | /* | ||
- | * We connect to the database, not the memcache server | + | * We connect to the database, not the memcache server |
- | */ | + | */ |
$db-> | $db-> | ||
/* | /* | ||
- | * look for a cached query with a life of 2400 seconds | + | * look for a cached query with a life of 2400 seconds |
- | */ | + | */ |
$sql = ' | $sql = ' | ||
$db-> | $db-> | ||
</ | </ | ||
+ | ===== Adding Weighted Server Groups ===== | ||
+ | From ADOdb version 5.22, the **memcached** library supports the use of **// | ||
+ | |||
+ | <code php> | ||
+ | array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | </ | ||
+ | |||
+ | The host arrays are then combined together. In this example 86.91 serves 70% of requests and 86.92 serves 30% | ||
+ | <code php> | ||
+ | |||
+ | $hosts = array( | ||
+ | array(' | ||
+ | array(' | ||
+ | ); | ||
+ | |||
+ | $db = NewADOConnection($driver=' | ||
+ | |||
+ | /* | ||
+ | * Enable memcache | ||
+ | */ | ||
+ | $db-> | ||
+ | |||
+ | /* | ||
+ | * Add the weighted servers | ||
+ | */ | ||
+ | $db-> | ||
+ | |||
+ | </ | ||
+ | |||
===== 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: | ||
+ | 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: | ||
+ | |||
+ | < | ||
+ | 3849805e4e026b9e7c485999a24a95c6 cache failure: Item with such key doesn' | ||
+ | (this is a notice and not an error) | ||
+ | -----< | ||
+ | |||
+ | (mysqli): SELECT * FROM employees | ||
+ | |||
+ | ------< | ||
+ | |||
+ | Notice: MemcachePool:: | ||
+ | SERVER_ERROR object too large for cache | ||
+ | (3) in C: | ||
+ | Failed to save data at the memcached server! | ||
+ | |||
+ | Cache write error | ||
+ | |||
+ | PHP Notice: | ||
+ | SERVER_ERROR object too large for cache (3) | ||
+ | in C: | ||
+ | </ | ||
- | 3849805e4e026b9e7c485999a24a95c6 cache failure: Item with such key doesn' | ||
- | (this is a notice and not an error) | ||
- | -----< | ||
- | | ||
- | (mysqli): SELECT * FROM employees | ||
- | | ||
- | -----< | ||
- | Notice: MemcachePool:: | ||
- | SERVER_ERROR object too large for cache | ||
- | (3) in C: | ||
- | Failed to save data at the memcached server! | ||
- | | ||
- | Cache write error | ||
- | | ||
- | PHP Notice: | ||
- | SERVER_ERROR object too large for cache (3) | ||
- | in C: | ||
- | | ||
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> | {{tag> | ||
+ |
v5/userguide/memcached.txt · Last modified: 2022/03/29 18:29 by dregad