Module: Sequel::Plugins::ActsAsCacheable::InstanceMethods

Defined in:
lib/sequel_acts_as_cacheable.rb

Instance Method Summary collapse

Instance Method Details

#cache!Object



75
76
77
78
79
80
81
82
83
# File 'lib/sequel_acts_as_cacheable.rb', line 75

def cache!
  unless new?
    marshallable!
    if respond_to? :before_cache
      before_cache
    end
    acts_as_cacheable_cache.set model_cache_key, self, acts_as_cacheable_time_to_live
  end
end

#cached?Boolean



91
92
93
# File 'lib/sequel_acts_as_cacheable.rb', line 91

def cached?
  acts_as_cacheable_cache.get(model_cache_key).present?
end

#deleteObject



101
102
103
104
105
# File 'lib/sequel_acts_as_cacheable.rb', line 101

def delete
  result = super
  invalidate_cache!
  result
end

#destroy(opts = {}) ⇒ Object



107
108
109
110
111
# File 'lib/sequel_acts_as_cacheable.rb', line 107

def destroy opts = {}
  result = super opts
  invalidate_cache! unless false == result
  result
end

#save(*columns) ⇒ Object



95
96
97
98
99
# File 'lib/sequel_acts_as_cacheable.rb', line 95

def save *columns
  result = super *columns
  invalidate_cache! if result && !new?
  result
end

#uncache!Object Also known as: invalidate_cache!



85
86
87
# File 'lib/sequel_acts_as_cacheable.rb', line 85

def uncache!
  acts_as_cacheable_cache.delete self.class.model_cache_key id
end