Module: Openstack::Helpers::CacheReaderable

Included in:
Client::Authenticator
Defined in:
lib/openstack/helpers/cache_readerable.rb

Overview

Methods to interact with cache.

Instance Method Summary collapse

Instance Method Details

#cache_keyObject



7
8
9
# File 'lib/openstack/helpers/cache_readerable.rb', line 7

def cache_key
  "openstack/token-#{username}"
end

#null_cache_placeholderObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/openstack/helpers/cache_readerable.rb', line 17

def null_cache_placeholder
  {
    'headers' => nil,
    'token' => nil,
    'expires_at' => nil,
    'code' => nil,
    'message' => nil,
    'body' => nil
  }
end

#read_from_cacheObject



11
12
13
14
15
# File 'lib/openstack/helpers/cache_readerable.rb', line 11

def read_from_cache
  @read_from_cache ||= JSON.parse(cache.read(cache_key))
rescue TypeError
  null_cache_placeholder
end