Module: CacheMethod::InstanceMethods
- Defined in:
- lib/cache_method.rb
Overview
All Objects, including instances and Classes, get the #cache_method_clear
method.
Instance Method Summary collapse
- #cache_method_cached?(method_id, *args) ⇒ Boolean
-
#cache_method_clear(method_id) ⇒ Object
Clear the cache for a particular method.
Instance Method Details
#cache_method_cached?(method_id, *args) ⇒ Boolean
75 76 77 |
# File 'lib/cache_method.rb', line 75 def cache_method_cached?(method_id, *args) ::CacheMethod::CachedResult.new(self, method_id, nil, nil, args).exist? end |
#cache_method_clear(method_id) ⇒ Object
Clear the cache for a particular method.
Note: Remember to define #as_cache_key
on any object whose instance methods might get cached.
Example:
my_blog.cache_method_clear :get_latest_entries
67 68 69 70 71 72 73 |
# File 'lib/cache_method.rb', line 67 def cache_method_clear(method_id) if ::CacheMethod.config.generational? ::CacheMethod::Generation.new(self, method_id).mark_passing else raise ::RuntimeError, "[cache_method] cache_method_clear called, but you have disabled generational caching. Check your setting for CacheMethod.config.generational" end end |