class Safelylaunch::HttpCache
Constants
- Value
Public Class Methods
new()
click to toggle source
# File lib/safelylaunch/http_cache.rb, line 7 def initialize @hash = Concurrent::Map.new end
Public Instance Methods
get(key)
click to toggle source
# File lib/safelylaunch/http_cache.rb, line 16 def get(key) value = @hash[key] if value && (Time.new.to_i < value.expired_time) value.data else @hash.delete(key) nil end end
keys()
click to toggle source
only for tests
# File lib/safelylaunch/http_cache.rb, line 28 def keys @hash.keys end
put(key, payload, expired_in)
click to toggle source
# File lib/safelylaunch/http_cache.rb, line 11 def put(key, payload, expired_in) @hash.put_if_absent(key, Value.new(Time.new.to_i + expired_in, payload)) payload end