class RailsCache

Public Class Methods

new(config={}) click to toggle source

Construct a new Rails cache object.

# File lib/handset_detection/cache/rails.rb, line 30
def initialize(config={})
  unless defined? Rails
    raise "Cannot access Rails."
  end
  @cache = Rails.cache 
end

Public Instance Methods

del(key) click to toggle source

Delete key

# File lib/handset_detection/cache/rails.rb, line 51
def del(key)
  @cache.delete key
end
flush() click to toggle source

Flush cache

# File lib/handset_detection/cache/rails.rb, line 56
def flush
  @cache.clear
end
get(key) click to toggle source

Get key

# File lib/handset_detection/cache/rails.rb, line 39
def get(key)
  @cache.read key
end
set(key, data, ttl) click to toggle source

Set key

# File lib/handset_detection/cache/rails.rb, line 45
def set(key, data, ttl)
  @cache.write key, data, expires_in: ttl
end