Evaluating Memcached for our site. Looking for advice.
John Kramlich
john.kramlich at gigoit.org
Sat Oct 20 15:30:05 UTC 2007
Jason Gross wrote:
> 1. Are there tools that exist to help analyze which queries should be
> cached?
If you are running MySQL you can enable logging of slow queries. You
can specify how many seconds something would have to take before you
consider it to be a slow query.
http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html
>
> 3. What level of effort was required to integrate memcached into the
> application?
>
Our SQL queries at Gigoit are very consistent and were easy to cache. I
wrote a PHP class that sits between our application and MySQL. Any
database queries call the query method in my class instead of
communicating directly with MySQL. I pass two parameters, the SQL query
and the number of seconds to keep the result set cached (0 for no
caching). The method returns a multidimensional array of the result set.
So, if you wanted to perform something like "SELECT username, email FROM
users" and keep it cached for two minutes the code would be:
MyClass->query('SELECT username, email FROM users',120);
We wrote the app from the ground up knowing we would use memcache so
your mileage my vary.
- John
---------------------------------
John Kramlich
toll-free: 1-877-2GIGOIT ext 701
More information about the memcached
mailing list