Class: Cerner::OAuth1a::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/cerner/oauth1a/cache.rb

Overview

Internal: A simple cache abstraction for use by AccessTokenAgent only.

Direct Known Subclasses

DefaultCache, RailsCache

Defined Under Namespace

Classes: AccessTokenEntry, DefaultCache, KeysEntry

Constant Summary collapse

ONE_HOUR =
3_600
TWENTY_FOUR_HOURS =
24 * ONE_HOUR

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCache

Internal: The base constructor for the interface.



116
# File 'lib/cerner/oauth1a/cache.rb', line 116

def initialize; end

Class Method Details

.instanceObject

Internal: Gets the singleton instance.



17
18
19
20
21
22
23
# File 'lib/cerner/oauth1a/cache.rb', line 17

def self.instance
  @cache_instance_lock.synchronize do
    return @cache_instance if instance_variable_defined?(:@cache_instance) && @cache_instance

    @cache_instance = DefaultCache.new(max: 50)
  end
end

.instance=(cache_impl) ⇒ Object

Internal: Sets the singleton instance.

Raises:

  • (ArgumentError)


10
11
12
13
14
# File 'lib/cerner/oauth1a/cache.rb', line 10

def self.instance=(cache_impl)
  raise ArgumentError, 'cache_impl must not be nil' unless cache_impl

  @cache_instance_lock.synchronize { @cache_instance = cache_impl }
end

Instance Method Details

#full_key(namespace, key) ⇒ Object

Internal: Constructs a single, fully qualified key based on the namespace and key value passed.

namespace - The namespace for the cache entries. key - The key for the cache entries.



136
137
138
# File 'lib/cerner/oauth1a/cache.rb', line 136

def full_key(namespace, key)
  "#{namespace}:#{key}"
end

#get(namespace, key) ⇒ Object

Internal: Retrieves the entry, if available, from the cache store.

namespace - The namespace for the cache entries. key - The key for the cache entries.



129
# File 'lib/cerner/oauth1a/cache.rb', line 129

def get(namespace, key); end

#put(namespace, key, entry) ⇒ Object

Internal: The abstract operation for putting (storing) data in the cache.

namespace - The namespace for the cache entries. key - The key for the cache entries, which is qualified by namespace. entry - The entry to be stored in the cache.



123
# File 'lib/cerner/oauth1a/cache.rb', line 123

def put(namespace, key, entry); end