class Reactor::Cache::User
Constants
- BACKING_CACHE_EXPIRATION
Public Class Methods
instance()
click to toggle source
# File lib/reactor/cache/user.rb, line 7 def self.instance self.new end
new()
click to toggle source
# File lib/reactor/cache/user.rb, line 11 def initialize @@backing_storage ||= ActiveSupport::Cache::MemoryStore.new({ size: 1.megabyte }) end
Public Instance Methods
get(user_name)
click to toggle source
# File lib/reactor/cache/user.rb, line 15 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
invalidate(user_name)
click to toggle source
# File lib/reactor/cache/user.rb, line 29 def invalidate(user_name) @@backing_storage.delete(user_name.to_s) end
set(user_name, user)
click to toggle source
# File lib/reactor/cache/user.rb, line 25 def set(user_name, user) @@backing_storage.write(user_name.to_s, user, :expires_in => BACKING_CACHE_EXPIRATION.minutes) end