Class: Sinicum::Jcr::Cache::GlobalCache

Inherits:
Object
  • Object
show all
Includes:
ApiClient
Defined in:
lib/sinicum/jcr/cache/global_cache.rb

Overview

Public: Fetches the global cache key from the JCR server.

Constant Summary collapse

API_PATH =
"/_cache/global"
JSON_CACHE_KEY =
"cacheKey"

Instance Method Summary collapse

Methods included from ApiClient

#api_get, #api_post

Methods included from Logger

included, #logger

Instance Method Details

#current_keyObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sinicum/jcr/cache/global_cache.rb', line 10

def current_key
  result = nil
  response = api_get(API_PATH)
  if response.ok?
    begin
      json = MultiJson.load(response.body)
      result = json[JSON_CACHE_KEY]
    rescue => e
      Rails.logger.error("Cannot load global cache key: " + e.message)
    end
  end
  result
end