Sha256: 8d6fbbef81150840c11670d08c73504b3c0e6cd3511f52f8d9473e2594b87b01
Contents?: true
Size: 857 Bytes
Versions: 6
Compression:
Stored size: 857 Bytes
Contents
require 'iron_cache' require 'uuidtools' module IronCacher CACHE_NAME='bridge-troll' DEFAULT_EXPIRES_IN = 60*5 def iron_cache_client IronCache::Client.new(project_id: ENV['IRON_CACHE_PROJECT_ID'], token: ENV['IRON_CACHE_TOKEN']) end def iron_cache(cache_name=CACHE_NAME) iron_cache_client.cache(cache_name) end def add_to_cache(token, task_id, cache_name=CACHE_NAME) iron_cache(cache_name).put(token, task_id, expires_in: IronCacher::DEFAULT_EXPIRES_IN) token end def retrieve_from_cache(token, cache_name=CACHE_NAME) if item=iron_cache(cache_name).get(token) return item.value end end def random_key_and_value(cache_name) key = UUIDTools::UUID.random_create.to_s value = UUIDTools::UUID.random_create.to_s add_to_cache(key, value, cache_name) return [key, value] end end
Version data entries
6 entries across 6 versions & 1 rubygems