Class: Valkyrie::Persistence::Fedora::OrderedList::NodeCache

Inherits:
Object
  • Object
show all
Defined in:
lib/valkyrie/persistence/fedora/ordered_list.rb

Overview

Class used for caching LinkedNode objects mapped to URIs

Instance Method Summary collapse

Constructor Details

#initializeNodeCache

Returns a new instance of NodeCache.



107
108
109
# File 'lib/valkyrie/persistence/fedora/ordered_list.rb', line 107

def initialize
  @cache ||= {}
end

Instance Method Details

#fetch(uri) ⇒ ListNode

Retrieve the ListNode for a given URI If a block is passed, set its output to the cache

Parameters:

Returns:



115
116
117
# File 'lib/valkyrie/persistence/fedora/ordered_list.rb', line 115

def fetch(uri)
  @cache[uri] ||= yield if block_given?
end

#key?(key) ⇒ Boolean

Determines whether or not the cache contains a key

Parameters:

  • key (Object)

Returns:

  • (Boolean)


122
123
124
# File 'lib/valkyrie/persistence/fedora/ordered_list.rb', line 122

def key?(key)
  @cache.key?(key)
end