Class: Orchestrate::Application::SimpleCacheRequest
- Inherits:
-
Object
- Object
- Orchestrate::Application::SimpleCacheRequest
- Defined in:
- lib/orchestrate_application/simple_cache_request.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
- #get(key) ⇒ Object
- #get_events(key, event_type) ⇒ Object
- #get_graph(key, kind) ⇒ Object
-
#initialize(collection) ⇒ SimpleCacheRequest
constructor
A new instance of SimpleCacheRequest.
- #save_event(key, event_type) ⇒ Object
- #save_graph(key, kind) ⇒ Object
Constructor Details
#initialize(collection) ⇒ SimpleCacheRequest
Returns a new instance of SimpleCacheRequest.
6 7 8 9 10 |
# File 'lib/orchestrate_application/simple_cache_request.rb', line 6 def initialize(collection) # puts "CACHE-init: '#{collection}'" @collection = collection @@cache_store ||= SimpleCacheStore.instance end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
4 5 6 |
# File 'lib/orchestrate_application/simple_cache_request.rb', line 4 def collection @collection end |
Instance Method Details
#enabled? ⇒ Boolean
12 13 14 |
# File 'lib/orchestrate_application/simple_cache_request.rb', line 12 def enabled? cache.is_enabled? end |
#get(key) ⇒ Object
16 17 18 19 20 21 |
# File '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) ⇒ Object
34 35 36 37 38 39 |
# File '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) ⇒ Object
23 24 25 26 27 28 |
# File '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) ⇒ Object
41 42 43 |
# File '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) ⇒ Object
30 31 32 |
# File '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 |