Ive recently implemented memcache on my site which has been under heavy mysql load (mysql was as optimized as I could make it). It solved all my load issues, and site is running
You may benefit from a simpler naming scheme for your memcached keys - so they are easier to delete. Seems like with the MD5 solution, you might be creating too many keys for things which generally show the same data.
You might also consider a shorter cache time, like 20 minutes?
Also - how many items per page are you retrieving for each of these search result pages? If you have a paginated search - getting 50 items from the server shouldn't be too intensive.
You may have tuned the mysql server, but have you tuned the queries (improving them by examining the EXPLAIN output), or table structures (by adding useful indexes)?
I'm also wondering how intense the queries on those pages are. Do you join several tables? You may benefit from doing a simpler query - or a few queries (outlined below).
Alternatively - For each row in the result, do you run another query - or several? You may benefit from a slightly more complex search query that avoids you having to do the nested queries. Or, are you being bitten by an ORM library which does the same thing, runs a search, then queries for sub items on each iteration?
The 'a few simpler queries' solution - say for example - if you've got an item, and want to know it's category in the result set...
In stead of this:
SELECT i.id, i.name,
c.category FROM items AS i
INNER JOIN categories AS c
ON i.category_id = c.id;
This is a simple example - but say there were categories, and several other JOINs involved.
You might go this route:
// run this query
SELECT id, category FROM categories - and put that into a keyed array.
// then in PHP create an array keyed by the id
$categories = array();
while ( false !== ( $row = mysql_fetch_assoc ( $result ) ) )
{
$categories[ $row['id'] ] = $row['category'];
}
// and so on
$types = array(); // ...
// etc.
Then do your search but without all of the JOINS, just from the items table with your where clauses, and in the output say...
Category:
Type:
It's a little ghetto, but maybe this - and the other suggestions - will help.