Unless you are supporting multiple databases, the extra overhead of ADODB is generally not worth it. Its serializing the value and using an md5 of the query as the cache key name. Unnecessary overhead and it will make deleting cache keys a pain in the ass for a large application.

If your application doesn't need to delete cache keys, then it wouldn't be too much of a problem.

Since I deal a lot in MVC environments, I created a function called simple_model(). Since much of the queries it runs are very simple check memcache, if not run this query and fetch the results. It really helps cut down on redundant code and simplifies caching.

Yes, I know it doesn't deal with negative cache results :)

function simple_model($query,$memcache_key,$ttl = NULL,$use_memcache = False)
{
        if ($use_memcache)
        {
                $result = cache::get($memcache_key);
        }

        if (! $result)
        {
                $dbr = mysql_query($query);
                mysql_check_error($dbr);

                while ($row = mysql_fetch_assoc($dbr))
                {
                        $result[] = $row;
                }

                if ($use_memcache)
                {
                        cache::set($memcache_key,$result,$ttl);
                }
        }

        return $result;
}


On Jul 13, 2009, at 10:34 AM, Patrick May wrote:


Sounds like you are looking for ADODB:
http://phplens.com/lens/adodb/docs-adodb.htm#memcache

On Jun 24, 3:44 am, Markus <[email protected]> wrote:
My apologies if this mail may appear slightly off-topic.

Is there a php database abstraction layer which uses memcached for caching?

tnx!

Reply via email to