class Soulheart::Base
Attributes
type[RW]
Public Instance Methods
cache_duration()
click to toggle source
# File lib/soulheart/base.rb, line 11 def cache_duration 10 * 60 # Setting to 10 minutes, but making it possible to edit down the line end
cache_id(type = 'all')
click to toggle source
# File lib/soulheart/base.rb, line 70 def cache_id(type = 'all') "#{Soulheart.base_id}cache:#{type}:" end
categories_id()
click to toggle source
# File lib/soulheart/base.rb, line 45 def categories_id "#{Soulheart.base_id}categories:" end
category_combos()
click to toggle source
# File lib/soulheart/base.rb, line 41 def category_combos redis.smembers(category_combos_id) end
category_combos_id()
click to toggle source
# File lib/soulheart/base.rb, line 37 def category_combos_id "#{Soulheart.base_id}category_combos:" end
category_id(name = 'all')
click to toggle source
# File lib/soulheart/base.rb, line 53 def category_id(name = 'all') "#{categories_id}#{name}:" end
combinatored_category_array()
click to toggle source
# File lib/soulheart/base.rb, line 23 def combinatored_category_array 1.upto(sorted_category_array.size). flat_map { |n| sorted_category_array.combination(n). map { |el| el.join('') } } end
no_query_id(category = category_id)
click to toggle source
# File lib/soulheart/base.rb, line 57 def no_query_id(category = category_id) "all:#{category}" end
normalize_type_id()
click to toggle source
# File lib/soulheart/base.rb, line 65 def normalize_type_id "#{Soulheart.base_id}normalize:" end
redis()
click to toggle source
# File lib/soulheart/base.rb, line 7 def redis Soulheart.redis end
results_hashes_id()
click to toggle source
# File lib/soulheart/base.rb, line 61 def results_hashes_id "#{Soulheart.base_id}database:" end
set_category_combos_array()
click to toggle source
# File lib/soulheart/base.rb, line 29 def set_category_combos_array redis.expire category_combos_id, 0 array = combinatored_category_array array.any? ? array.last.replace('all') : array << 'all' redis.sadd category_combos_id, array array end
sorted_category_array()
click to toggle source
# File lib/soulheart/base.rb, line 15 def sorted_category_array redis.smembers(categories_id).map { |c| normalize(c) }.uniq.sort end