Module: CachedResource::Caching::ClassMethods

Defined in:
lib/cached_resource/caching.rb

Instance Method Summary collapse

Instance Method Details

#clear_cache(options = nil) ⇒ Object

Clear the cache.



28
29
30
31
32
# File 'lib/cached_resource/caching.rb', line 28

def clear_cache(options = nil)
  cache_clear(options)

  true
end

#find_with_cache(*arguments) ⇒ Object

Find a resource using the cache or resend the request if :reload is set to true or caching is disabled.



17
18
19
20
21
22
23
24
25
# File 'lib/cached_resource/caching.rb', line 17

def find_with_cache(*arguments)
  arguments << {} unless arguments.last.is_a?(Hash)
  should_reload = arguments.last.delete(:reload) || !cached_resource.enabled
  should_reload = true if !cached_resource.cache_collections && is_any_collection?(*arguments)
  arguments.pop if arguments.last.empty?
  key = cache_key(arguments)

  should_reload ? find_via_reload(key, *arguments) : find_via_cache(key, *arguments)
end