Skip to content

Latest commit

 

History

History
71 lines (48 loc) · 1.4 KB

File metadata and controls

71 lines (48 loc) · 1.4 KB

Rails gem to generate cache versions for your model It allows to have several versions with keys to identify them.

soon...
script/plugin install git://github.com/dwaynemac/cache_version.git

Two methods are provided to the model.

returns a string representing version for this model under key. if consider_update_key is true version has the following format: cache_key/key:key_version else version has the following format: class_nameModel_id/key:key_version

increments by one version for given key and returns it. consider_updated_at is only needed if you’ll use returned value.

class Product
  cache_version

  ...
end
class Reseller
  after_save :update_product

  def update_product
    self.product.increment_version('resellers')
  end
end
<h1>Buyers</h1>
<%- cache(product.version('buyers',false)) do -%>
 ...
<%- end -%>

<h1>Resellers</h1>
<%- cache(product.version('resellers')) do -%>
 ...
<%- end -%>

Internally CacheVersion uses module Version wich is also made available for the application. This module provides