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



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

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

#read(key) ⇒ Object



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

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

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



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

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