Sha256: 9d8fd6bd81119618c261dfa45159d9cadbad4af22cde790d51e38d62116fe82c
Contents?: true
Size: 509 Bytes
Versions: 24
Compression:
Stored size: 509 Bytes
Contents
# frozen_string_literal: true ## # Middleware responsible for storing and # invalidating cache. class MemoryInvalidationMiddleware attr_accessor :cache, :mutex def initialize(inv_time_seconds = 3_600) @cache = {} @mutex = Mutex.new Thread.new do loop do sleep(1) @mutex.synchronize do @cache.each_pair do |key, value| @cache.delete(key) if Time.now - value[1] >= inv_time_seconds end end end end sleep(2) end end
Version data entries
24 entries across 24 versions & 1 rubygems