Module: RuCaptcha::Cache::ClassMethods
- Defined in:
- lib/rucaptcha/cache.rb
Instance Method Summary collapse
- #cache ⇒ Object
- #cached_codes ⇒ Object
- #create_with_cache(code) ⇒ Object
- #random_chars_with_cache ⇒ Object
Instance Method Details
#cache ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rucaptcha/cache.rb', line 32 def cache return @cache if defined?(@cache) cache_path = Rails.root.join('tmp', 'cache', 'rucaptcha') if !File.exists? cache_path FileUtils.mkdir_p(cache_path) end @cache = ActiveSupport::Cache::FileStore.new(cache_path) @cache.clear @cache end |
#cached_codes ⇒ Object
44 45 46 |
# File 'lib/rucaptcha/cache.rb', line 44 def cached_codes @cached_codes ||= [] end |
#create_with_cache(code) ⇒ Object
16 17 18 19 20 |
# File 'lib/rucaptcha/cache.rb', line 16 def create_with_cache(code) cache.fetch(code) do create_without_cache(code) end end |