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.



109
110
111
# File 'lib/valkyrie/persistence/fedora/ordered_list.rb', line 109

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:



117
118
119
# File 'lib/valkyrie/persistence/fedora/ordered_list.rb', line 117

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)


124
125
126
# File 'lib/valkyrie/persistence/fedora/ordered_list.rb', line 124

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