ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:learn_caching:cache_problems

Solving Problems With Caching

Unexpected Results

Finding cached result sets is dependent on there being an exact query match on the SQL statement issued, so for example:

SELECT code,description FROM table ORDER BY code

and

SELECT code,description FROM table ORDER BY code ASC

Whilst the result set produced by the query in both queries would be exactly the same, because the checksums of the queries are different, they would not return the same cached query. The easiest way to avoid such errors is to define constants for queries and reuse them as such

DEFINE ('CACHED_RESULT', 'SELECT code,description FROM table ORDER BY code ASC');
 
$result = $db->cacheGetAssoc(2400,CACHED_RESULT);

Disk Based Caching

The most common problem with using disk-based caching is the result of ownership permissions on the directories used for storing the cached result sets. Problems can be exacerbated under the following circumstances:

  • Executing queries in both a web server and CLI environment, where multiple user and group ID numbers are in use
  • Under IIS, use of multiple Application Pools with different identities

Memcached Caching

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.

End Of Tutorial

v5/userguide/learn_caching/cache_problems.txt · Last modified: 2016/03/29 05:00 by mnewnham