Sha256: 66fbbadb2c460ab0481305b05b992cee9a9abaa74d9bf95fa2759b0fcf50e50f
Contents?: true
Size: 781 Bytes
Versions: 2
Compression:
Stored size: 781 Bytes
Contents
module CloudSesame module Domain module ClientModule module Caching class RailsCache < Base def initialize(searchable, &lazy_client) ensure_environment_exists super end def fetch(params) Rails.cache.fetch(hashify(params)) do results = search params OpenStruct.new(status: results.status, hits: results.hits, facets: results.facets) end end private def hashify(params) searchable_params = params.merge(searchable: @searchable) Digest::MD5.hexdigest Marshal.dump(searchable_params) end def ensure_environment_exists unless RailsCache.const_defined?(:Rails) raise Error::Caching, "Rails environment cannot be found" end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
CloudSesame-0.6.7 | lib/cloud_sesame/domain/client_module/caching/rails_cache.rb |
CloudSesame-0.6.6 | lib/cloud_sesame/domain/client_module/caching/rails_cache.rb |