Sha256: 17ef672257aec3a7d82989bb8e6241911e09d670149baefe5132cc2f82d62502
Contents?: true
Size: 498 Bytes
Versions: 1
Compression:
Stored size: 498 Bytes
Contents
# frozen_string_literal: true ## # Middleware responsible for storing and # invalidating cache. class CachingMiddleware 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
macaw_framework-1.0.0 | lib/macaw_framework/middlewares/caching_middleware.rb |