Class: AWS::Core::ResponseCache
- Inherits:
-
Object
- Object
- AWS::Core::ResponseCache
- Defined in:
- lib/aws/core/response_cache.rb
Instance Attribute Summary collapse
-
#cached_responses ⇒ Object
readonly
Returns the value of attribute cached_responses.
-
#resource_cache ⇒ Object
readonly
Returns the value of attribute resource_cache.
Instance Method Summary collapse
- #add(resp) ⇒ Object
- #cached(resp) ⇒ Object
-
#initialize ⇒ ResponseCache
constructor
A new instance of ResponseCache.
- #select(*types, &block) ⇒ Object
Constructor Details
#initialize ⇒ ResponseCache
Returns a new instance of ResponseCache.
24 25 26 27 28 |
# File 'lib/aws/core/response_cache.rb', line 24 def initialize @cached_responses = [] @indexed_responses = {} @resource_cache = ResourceCache.new end |
Instance Attribute Details
#cached_responses ⇒ Object (readonly)
Returns the value of attribute cached_responses.
20 21 22 |
# File 'lib/aws/core/response_cache.rb', line 20 def cached_responses @cached_responses end |
#resource_cache ⇒ Object (readonly)
Returns the value of attribute resource_cache.
22 23 24 |
# File 'lib/aws/core/response_cache.rb', line 22 def resource_cache @resource_cache end |
Instance Method Details
#add(resp) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/aws/core/response_cache.rb', line 30 def add(resp) cached_responses.unshift(resp) @indexed_responses[resp.cache_key] = resp if resp.respond_to?(:cache_key) @resource_cache = ResourceCache.new end |
#cached(resp) ⇒ Object
44 45 46 |
# File 'lib/aws/core/response_cache.rb', line 44 def cached(resp) @indexed_responses[resp.cache_key] end |
#select(*types, &block) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/aws/core/response_cache.rb', line 37 def select(*types, &block) cached_responses.select do |resp| types.map{|t| t.to_s }.include?(resp.request_type.to_s) and (block.nil? || block.call(resp)) end end |