-
bundle install -
rake db:migrate -
Make sure you have
redisinstalled:brew install redis -
Make sure
redisis running,redis-server -
foreman start(to run both the web/worker processes)
-
If a
product_searchexists matchingqueryAND has acached_atwithin 7 days- show that one
-
If a
product_searchexists matchingqueryBUT has acached_atolder than 7 days- this one is expired
- delete all associated
resultrecords - fetch and associate a new result set
- update the
cached_atdate toDate.current
-
If NO
product_searchexists for aquery- create a new one and populate the results
Pros
- For frequently requested
query's we have a positivecache_hitevery time (minus one every 7 days). - Avoid a cache stampede, by avoiding a mass
cache_refreshall at once.
Cons
- Infrequently requested
queryresults may not have their cache busted often, or with any regularity (maybe this is okay?) - We might be needlessly updating caches every 7 days if result sets do not change within that time interval.
- Currently I call
destroy_allduring a re-saturation ofresultsfor a particularproduct_search- This produces a
DELETE FROMquery for each associatedresultrecord, which is ann+1situation :(
- This produces a
- Did not implement pagination, however, based on the docs for the
semantic3gem, it appears as though one might pass through anoffsetparameter into theget_products()endpoint.