Skip to content

tulak/table_checksum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

table_checksum

Gem adds methods to the ActiveRecord::Base classes to easily generate checksum of some table using CREATE CHECKSUM `table_name`; syntax

User.checksum # => ["database.users", 2513815180]

This is useful for fragment caching when you list all records from table in cached partial

<% cache [@event, User.checksum] do %>
  ...
    <%= f.collection_select :user_id, @users || User.all, :id, :name %>
  ...
<% end %>

You can also omit the checksum method because ActiveRecord::Base now responds to cache_key method

<% cache [@event, User] do %>

It also uses PerRequestCache for performance.

I tried to write the PerRequestCache as much threadsafe as i could

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages