Module: PuppetForgeServer::Utils::CacheProvider

Included in:
Http::HttpClient, Server
Defined in:
lib/puppet_forge_server/utils/cache_provider.rb

Constant Summary collapse

@@CACHE =
LRUCache.new(:ttl => opts[:ram_cache_ttl], :max_size => opts[:ram_cache_size])

Instance Method Summary collapse

Instance Method Details

#cache_instanceLRUCache

Method for fetching application wide cache for fetching HTTP requests

Returns:

  • (LRUCache)

    a instance of cache for application



28
29
30
# File 'lib/puppet_forge_server/utils/cache_provider.rb', line 28

def cache_instance
  @@CACHE
end

#configure_cache(ttl, size) ⇒ Object

Configure a application wide cache using LSUCache implementation

Parameters:

  • ttl (int)

    a time to live for elements

  • size (int)

    a maximum size for cache



36
37
38
39
40
# File 'lib/puppet_forge_server/utils/cache_provider.rb', line 36

def configure_cache(ttl, size)
  @@CACHE = LRUCache.new(:ttl => ttl, :max_size => size)
  PuppetForgeServer::Logger.get.info("Using RAM memory LRUCache with time to live of #{ttl}sec and max size of #{size} elements")
  nil
end