Module: Sequel::Plugins::Cacheable::InstanceMethods
- Defined in:
- lib/sequel-cacheable/instance_methods.rb
Instance Method Summary collapse
- #after_initialize ⇒ Object
- #after_save ⇒ Object
- #cache! ⇒ Object
- #cache_key ⇒ Object
- #delete(*args) ⇒ Object
- #recache! ⇒ Object
- #to_msgpack(*args) ⇒ Object
- #uncache! ⇒ Object
Instance Method Details
#after_initialize ⇒ Object
6 7 8 9 |
# File 'lib/sequel-cacheable/instance_methods.rb', line 6 def after_initialize super cache! unless id.nil? end |
#after_save ⇒ Object
11 12 13 14 |
# File 'lib/sequel-cacheable/instance_methods.rb', line 11 def after_save super recache! end |
#cache! ⇒ Object
21 22 23 |
# File 'lib/sequel-cacheable/instance_methods.rb', line 21 def cache! model.cache_set(cache_key, self) end |
#cache_key ⇒ Object
35 36 37 |
# File 'lib/sequel-cacheable/instance_methods.rb', line 35 def cache_key "#{self.id.to_s}" end |
#delete(*args) ⇒ Object
16 17 18 19 |
# File 'lib/sequel-cacheable/instance_methods.rb', line 16 def delete(*args) uncache! super end |
#recache! ⇒ Object
30 31 32 33 |
# File 'lib/sequel-cacheable/instance_methods.rb', line 30 def recache! uncache! cache! end |
#to_msgpack(*args) ⇒ Object
39 40 41 |
# File 'lib/sequel-cacheable/instance_methods.rb', line 39 def to_msgpack(*args) msgpack_hash.to_msgpack end |
#uncache! ⇒ Object
25 26 27 28 |
# File 'lib/sequel-cacheable/instance_methods.rb', line 25 def uncache! model.cache_del(cache_key) model.cache_clear(:query) end |