class Orchestrate::Application::SimpleCacheRequest
Attributes
collection[R]
Public Class Methods
new(collection)
click to toggle source
# File rails/lib/orchestrate_application/simple_cache_request.rb, line 6 def initialize(collection) # puts "CACHE-init: '#{collection}'" @collection = collection @@cache_store ||= SimpleCacheStore.instance end
Public Instance Methods
enabled?()
click to toggle source
# File rails/lib/orchestrate_application/simple_cache_request.rb, line 12 def enabled? cache.is_enabled? end
get(key)
click to toggle source
# File rails/lib/orchestrate_application/simple_cache_request.rb, line 16 def get(key) doc = cache.get_cc(collection).fetch key path = "/local_cache/#{collection}/#{key}" puts "\n------- GET \"#{path}\" ------ #{doc ? 'OK' : 'not found'}" response([doc]) if doc end
get_events(key, event_type)
click to toggle source
# File rails/lib/orchestrate_application/simple_cache_request.rb, line 34 def get_events(key, event_type) docs = cache.get_cc(collection).fetch_events key, event_type path = "/local_cache/#{collection}/#{key}/events/#{event_type}" puts "\n------- GET \"#{path}\" ------ #{docs ? 'OK' : 'not found'}" response(docs) if docs end
get_graph(key, kind)
click to toggle source
# File rails/lib/orchestrate_application/simple_cache_request.rb, line 23 def get_graph(key, kind) docs = cache.get_cc(collection).fetch_graph key, kind path = "/local_cache/#{collection}/#{key}/graph/#{kind}" puts "\n------- GET \"#{path}\" ------ #{docs ? 'OK' : 'not found'}" response(docs) if docs end
save_event(key, event_type)
click to toggle source
# File rails/lib/orchestrate_application/simple_cache_request.rb, line 41 def save_event(key, event_type) cache.get_cc(collection).save_event Metadata.new(key: key, etype: event_type) end
save_graph(key, kind)
click to toggle source
# File rails/lib/orchestrate_application/simple_cache_request.rb, line 30 def save_graph(key, kind) cache.get_cc(collection).save_graph Metadata.new(from_key: key, kind: kind) end
Private Instance Methods
cache()
click to toggle source
# File rails/lib/orchestrate_application/simple_cache_request.rb, line 47 def cache @@cache_store end
response(docs)
click to toggle source
# File rails/lib/orchestrate_application/simple_cache_request.rb, line 51 def response(docs) locations = docs.map { |doc| location = "/local_cache/refs/#{doc.id}" puts " from \"#{location}\"" location } r_info = { locations: locations, code: 200, :status => :cache } r_info.merge!(etag: docs.first.id) if docs.length == 1 SimpleCacheResponse.new(r_info, docs) end