class AmaLayout::Notifications::RedisStore

Attributes

base[RW]

Public Class Methods

new(opts = {}) click to toggle source
# File lib/ama_layout/notifications/redis_store.rb, line 8
def initialize(opts = {})
  self.base = ActiveSupport::Cache.lookup_store(
    :redis_store,
    opts.merge(raw: true)
  )
end

Public Instance Methods

delete(key, opts = {}) click to toggle source
# File lib/ama_layout/notifications/redis_store.rb, line 27
def delete(key, opts = {})
  base.delete(key, opts)
end
get(key, opts = {}) click to toggle source
# File lib/ama_layout/notifications/redis_store.rb, line 15
def get(key, opts = {})
  if opts.fetch(:default, false)
    base.fetch(key) { opts[:default] }
  else
    base.read(key)
  end
end
set(key, value, opts = {}) click to toggle source
# File lib/ama_layout/notifications/redis_store.rb, line 23
def set(key, value, opts = {})
  base.write(key, value, opts)
end
transaction() { |self| ... } click to toggle source
# File lib/ama_layout/notifications/redis_store.rb, line 31
def transaction
  base.data.multi do
    yield self
  end
end