Module: Whoosh::Cache
- Defined in:
- lib/whoosh/cache.rb,
lib/whoosh/cache/redis_store.rb,
lib/whoosh/cache/memory_store.rb
Defined Under Namespace
Classes: MemoryStore, RedisStore
Class Method Summary collapse
-
.build(config_data = {}) ⇒ Object
Auto-detect: REDIS_URL set → Redis, otherwise → Memory.
Class Method Details
.build(config_data = {}) ⇒ Object
Auto-detect: REDIS_URL set → Redis, otherwise → Memory
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/whoosh/cache.rb', line 9 def self.build(config_data = {}) cache_config = config_data["cache"] || {} default_ttl = cache_config["default_ttl"] || 300 redis_url = ENV["REDIS_URL"] || cache_config["url"] if redis_url && cache_config["store"] != "memory" begin RedisStore.new(url: redis_url, default_ttl: default_ttl) rescue Errors::DependencyError # Redis gem not installed, fall back to memory MemoryStore.new(default_ttl: default_ttl) end else MemoryStore.new(default_ttl: default_ttl) end end |