Class: ActsAsTextcaptcha::TextcaptchaCache

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_textcaptcha/textcaptcha_cache.rb

Constant Summary collapse

KEY_PREFIX =
'acts_as_textcaptcha-'
DEFAULT_EXPIRY_MINUTES =
10

Instance Method Summary collapse

Instance Method Details

#delete(key) ⇒ Object



21
22
23
# File 'lib/acts_as_textcaptcha/textcaptcha_cache.rb', line 21

def delete(key)
  Rails.cache.delete(cache_key(key))
end

#read(key) ⇒ Object



17
18
19
# File 'lib/acts_as_textcaptcha/textcaptcha_cache.rb', line 17

def read(key)
  Rails.cache.read(cache_key(key))
end

#write(key, value, options = {}) ⇒ Object



10
11
12
13
14
15
# File 'lib/acts_as_textcaptcha/textcaptcha_cache.rb', line 10

def write(key, value, options = {})
  unless options.has_key?(:expires_in)
    options[:expires_in] = DEFAULT_EXPIRY_MINUTES.minutes
  end
  Rails.cache.write(cache_key(key), value, options)
end