Module: Sequel::Plugins::Caching::InstanceMethods
- Defined in:
- lib/sequel/plugins/caching.rb
Instance Method Summary collapse
-
#before_update ⇒ Object
Remove the object from the cache when updating.
-
#cache_key ⇒ Object
Return a key unique to the underlying record for caching, based on the primary key value(s) for the object.
-
#delete ⇒ Object
Remove the object from the cache when deleting.
Instance Method Details
#before_update ⇒ Object
Remove the object from the cache when updating
103 104 105 106 |
# File 'lib/sequel/plugins/caching.rb', line 103 def before_update return false if super == false cache_delete end |
#cache_key ⇒ Object
Return a key unique to the underlying record for caching, based on the primary key value(s) for the object. If the model does not have a primary key, raise an Error.
111 112 113 114 115 116 117 118 119 120 |
# File 'lib/sequel/plugins/caching.rb', line 111 def cache_key raise(Error, "No primary key is associated with this model") unless key = primary_key pk = case key when Array key.collect{|k| @values[k]} else @values[key] || (raise Error, 'no primary key for this record') end model.send(:cache_key, pk) end |
#delete ⇒ Object
Remove the object from the cache when deleting
123 124 125 126 |
# File 'lib/sequel/plugins/caching.rb', line 123 def delete cache_delete super end |