Sha256: 9beaed5b316525288519dab1cccb124dc81f7db6a4474ce7bbeaf29584ca6dd6
Contents?: true
Size: 836 Bytes
Versions: 8
Compression:
Stored size: 836 Bytes
Contents
module Reactor module Cache class User BACKING_CACHE_EXPIRATION = 5 def self.instance new end def initialize @@backing_storage ||= ActiveSupport::Cache::MemoryStore.new({ size: 1.megabyte }) end def get(user_name) @cache ||= {} # Rails.logger.debug "User:Cache hit: #{hit?(user_name.to_s)} [#{@cache[user_name.to_s].inspect}]" key = user_name.to_s @@backing_storage.fetch(key, expires_in: BACKING_CACHE_EXPIRATION.minutes) do Reactor::Session::User.new(key) end end def set(user_name, user) @@backing_storage.write(user_name.to_s, user, expires_in: BACKING_CACHE_EXPIRATION.minutes) end def invalidate(user_name) @@backing_storage.delete(user_name.to_s) end end end end
Version data entries
8 entries across 8 versions & 1 rubygems