ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:learn_caching:adodb_coding

This is an old revision of the document!


Using Cached Queries

ADOdb provides replacement functions that look for cached results, instead of querying the database directly. The names of the methods match the normal method names but with the word 'cache' prepended, e.g.

  • cacheGetOne replaces getOne
  • cacheExecute replaces execute

The format of the parameters in the cache methods matches that of the normal methods, except for the fact that the parameters are shifted one entry and the first parameter is always the TTL (Time-To-Live) of the query.

/*
* look for a cached query with a life of 2400 seconds
*/
$sql = 'SELECT code,description FROM xref_table';
$db->cacheExecute(2400,$sql);

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 debugging is enabled, then an error is displayed.

3849805e4e026b9e7c485999a24a95c6 cache failure: Item with such key doesn't exists on the memcached server.
(this is a notice and not an error)
-----<hr>

(mysqli): SELECT * FROM employees 

-----<hr>
Notice: MemcachePool::set(): Server 192.168.0.78 (tcp 11211, udp 0) failed with:
SERVER_ERROR object too large for cache
(3) in C:\dev\github\mssqlnative-fixes\adodb-memcache.lib.inc.php on line 94
Failed to save data at the memcached server!

Cache write error

PHP Notice:  MemcachePool::set(): Server 192.168.0.78 (tcp 11211, udp 0) failed with:
SERVER_ERROR object too large for cache (3) 
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.

v5/userguide/learn_caching/adodb_coding.1459206111.txt.gz · Last modified: 2017/04/21 11:40 (external edit)