Module: CachedResource::Caching::ClassMethods

Defined in:
lib/cached_resource/caching.rb

Instance Method Summary collapse

Instance Method Details

#clear_cacheObject

Clear the cache.



27
28
29
# File 'lib/cached_resource/caching.rb', line 27

def clear_cache
  cache_clear
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
# 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
  arguments.pop if arguments.last.empty?
  key = cache_key(arguments)

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