/** * cache searches by creating a checksum of the search parameters * to keep the cache more accurate we also keep a dynamic cache-bust key for certain parameters * so when listings affecting those parameters change the cache will be busted to reflect those changes. * * for example, let's say I was searching for all auctions from a given seller. When that seller * creates a new auction, a cache key will be updated for the seller. The value of that cache key are * always incorporated into my search checksum, so as a result the checksum changes and I instantly * see the new listing by that seller the moment the auction is created. * * only cache for a very short time if the search query is time sensitive. */ public function search($options) { $options = Util::SearchOptions($options); $search_vector = $this->searchVectors($options); $key = '-search-/' . md5(print_r($options->export(), TRUE) . $search_vector); $cache = $this->cache(); $res = $cache->get($key); if (is_array($res)) { return $res; } $res = $this->core->search($options); $timeout = $this->searchCacheTimeout(); if (in_array($options->sort, array('just_added', 'expires_soon', 'expires_soon_delay'))) { $timeout = 30; } $cache->set($key, $res, $timeout); return $res; }