[wp-hackers] MySQL HEAP Persistent Object Cache

Robert Deaton false.hopes at gmail.com
Thu Apr 19 06:17:29 GMT 2007


After much discussion with Andy and tossing ideas back and forth, I
finally sat down for two hours tonight and threw this together.

Here's the brief rundown, as I am fading quickly and have class in the morning.

This uses a special MySQL engine that stores the information in RAM,
which is much faster than storing to disk, which is what the default
object cache does. In theory, this object cache should be faster,
that's what I'd like you to help me find out :). This is intended to
help shared hosts once it is in a more final stage. There are a few
features I would still like to add.

To use it, download the file, make sure it is named "object-cache.php"
and stick it in your wp-contents/ directory.

Next, using the MySQL console, PHPmyAdmin, or whatever else, issue the
following query:
CREATE TABLE trunk_memcache (hash CHAR(32), num TINYINT, expires INT,
a CHAR(255) NOT NULL default '', b CHAR(255) NOT NULL default '', c
CHAR(255) NOT NULL default '', d CHAR(255) NOT NULL default '', INDEX
USING BTREE (hash,num), INDEX USING BTREE(expires)) ENGINE = MEMORY;

Then, open up your wp-config.php file, and insert the following line
somewhere before the require_once:
define('ENABLE_CACHE', true);

Useful data includes any change in load time from no cache or from the
default file-based object cache (rename your
wp-content/object-cache.php to enable the old object cache, always
make sure its actually writing to disk before sending in any
benchmarks).

Questions are welcome, both technical and non-technical. Any
benchmarks, either numeric or subjective, are welcome (I'd prefer the
numeric kind, of course). Enjoy.

[The file may be attached to this mail, if not, there is a text
version online. http://lushlab.com/plugins/mysql_heap_object_cache/ ]

-- 
--Robert Deaton
http://lushlab.com


More information about the wp-hackers mailing list