Memcache + Dynamic Query Filters

Les Mikesell lesmikesell at gmail.com
Mon Oct 1 00:17:07 UTC 2007


K J wrote:
>> I am trying to use memcached for a web application with search
>> functionality. All search queries work on certain number of parameters ( the
>> parameters are numbers or boolean ).
>> There is also an additional parameter ( date range ) which is also
>> attached to the query.
>>
>> One of my sample query ( sql ) looks like
>> select * from table where type = 1 and ( occurred_date between 'some date'
>> and 'some date');
>>
>> Has someone out here dealt with date range based querying using memcached
>> before or have any ideas around how to use ( if at all ) memcached for such
>> dynamic queries ?
> 
> 
> You could store each query indexed by the MD5 of the mysql query.  Then when
> doing a new query, search to see if it's already in the cache.


The problem with this is that if arbitrary ranges are allowed and 
everyone picks slightly different endpoints your query won't match even 
if most of the results are already in the cache. Has anyone used a 
scheme where the client breaks the range into chunks with consistent 
boundaries?

-- 
   Les Mikesell
    lesmikesell at gmail.com


More information about the memcached mailing list