futzing with redis a bit
This commit is contained in:
parent
048b3881f9
commit
0bca534c3e
@ -1,9 +1,20 @@
|
||||
module SolrHelper
|
||||
$select_url = 'http://localhost:8983/solr/select/'
|
||||
$redis = '/home/me/repos/redis.git/src/redis-cli'
|
||||
|
||||
def get_results(search)
|
||||
cached = `#{$redis} GET "query:#{search}"`
|
||||
|
||||
if cached.strip().length > 0
|
||||
# puts "cached=#{cached}"
|
||||
xml_results = REXML::Document.new cached
|
||||
else
|
||||
raw_results = open("#{$select_url}?q=#{search}").read
|
||||
# puts "caching '#{raw_results}'"
|
||||
`#{$redis} SET "query:#{search}" '#{raw_results}'`
|
||||
|
||||
xml_results = REXML::Document.new raw_results
|
||||
end
|
||||
|
||||
results = []
|
||||
REXML::XPath.each(xml_results, '//result/doc') do |doc|
|
||||
|
Loading…
Reference in New Issue
Block a user