module Spinel::Searcher

Public Instance Methods

cache_enable(key) click to toggle source
# File lib/spinel/searcher.rb, line 31
def cache_enable key
  Spinel.redis.exists(key)
end
search_option(options = {}) click to toggle source
# File lib/spinel/searcher.rb, line 17
def search_option options = {}
  { limit: Spinel.search_limit, cache: true }.merge(options)
end
search_word_split(word) click to toggle source
# File lib/spinel/searcher.rb, line 21
def search_word_split word
  squish(word).split.reject{|w| w.size < Spinel.minimal_word}.sort
end
set_cache(key, words) click to toggle source
# File lib/spinel/searcher.rb, line 25
def set_cache key, words
  interkeys = words.map{ |w| index w }
  Spinel.redis.zinterstore(key, interkeys)
  Spinel.redis.expire(key, Spinel.cache_expire)
end