Class: ActsAsTextcaptcha::TextcaptchaCache

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

Constant Summary

CACHE_KEY_PREFIX =
'acts_as_textcaptcha-'
DEFAULT_CACHE_EXPIRY_MINUTES =
10

Instance Method Summary collapse

Instance Method Details

#delete(key, options = nil) ⇒ Object



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

def delete(key, options = nil)
  Rails.cache.delete(cache_key(key), options)
end

#read(key, options = nil) ⇒ Object



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

def read(key, options = nil)
  Rails.cache.read(cache_key(key), options)
end

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



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

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