Class: ROM::Cache Private
- Inherits:
-
Object
- Object
- ROM::Cache
- Defined in:
- lib/rom/cache.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Thread-safe cache used by various rom components
Defined Under Namespace
Classes: Namespaced
Instance Attribute Summary collapse
- #objects ⇒ Object readonly private
Instance Method Summary collapse
- #[](key) ⇒ Object private
- #fetch_or_store(*args, &block) ⇒ Object private
-
#initialize ⇒ Cache
constructor
private
A new instance of Cache.
- #inspect ⇒ Object private
- #namespaced(namespace) ⇒ Object private
- #size ⇒ Object private
Constructor Details
#initialize ⇒ Cache
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Cache.
46 47 48 49 |
# File 'lib/rom/cache.rb', line 46 def initialize @objects = Concurrent::Map.new @namespaced = {} end |
Instance Attribute Details
#objects ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 |
# File 'lib/rom/cache.rb', line 8 def objects @objects end |
Instance Method Details
#[](key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 |
# File 'lib/rom/cache.rb', line 51 def [](key) cache[key] end |
#fetch_or_store(*args, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 |
# File 'lib/rom/cache.rb', line 56 def fetch_or_store(*args, &block) objects.fetch_or_store(args.hash, &block) end |
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
71 72 73 |
# File 'lib/rom/cache.rb', line 71 def inspect %(#<#{self.class} size=#{size} namespaced=#{@namespaced.inspect}>) end |
#namespaced(namespace) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
66 67 68 |
# File 'lib/rom/cache.rb', line 66 def namespaced(namespace) @namespaced[namespace] ||= Namespaced.new(objects, namespace) end |
#size ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 |
# File 'lib/rom/cache.rb', line 61 def size objects.size end |