Class: ROM::Cache Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeCache

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.



57
58
59
60
# File 'lib/rom/cache.rb', line 57

def initialize
  @objects = Concurrent::Map.new
  @namespaced = {}
end

Instance Attribute Details

#objectsObject (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.



10
11
12
# File 'lib/rom/cache.rb', line 10

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.



63
64
65
# File 'lib/rom/cache.rb', line 63

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.



68
69
70
# File 'lib/rom/cache.rb', line 68

def fetch_or_store(*args, &block)
  objects.fetch_or_store(args.hash, &block)
end

#inspectObject

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.



83
84
85
# File 'lib/rom/cache.rb', line 83

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.



78
79
80
# File 'lib/rom/cache.rb', line 78

def namespaced(namespace)
  @namespaced[namespace] ||= Namespaced.new(objects, namespace, parent: self)
end

#sizeObject

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.



73
74
75
# File 'lib/rom/cache.rb', line 73

def size
  objects.size
end