Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model class cache key #3

Merged
merged 6 commits into from
Aug 30, 2013
Merged

Conversation

equivalent
Copy link
Collaborator

Provides class method cache_key for model class

This can be used as parameter for Rails.cache.fetch

 Rails.cache.fetch [Post, 'last_posts'] do
   Post.last_posts
 end
 # => Cache fetch_hit: Post-1377768216/last_posts 

@ghost ghost assigned delwyn Aug 29, 2013

context 'when no record exist' do
before{ User.destroy_all }
it{ subject; subject.must_equal "User-0" }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the subject; needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ups didn't see that

# SELECT MAX(`posts`.`cached_at`) AS max_id FROM `posts`
# => "Post-1377768216"

You can use this inside your cachin syntax when you are monitoring if model was changed.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cachin typo. Also this does not read well. Can you change it too something like 'You can use the model to generate cache keys'

@equivalent
Copy link
Collaborator Author

good to go ?

delwyn added a commit that referenced this pull request Aug 30, 2013
@delwyn delwyn merged commit 260c340 into delwyn:master Aug 30, 2013
@delwyn
Copy link
Owner

delwyn commented Aug 30, 2013

thanks

@equivalent equivalent deleted the model_class_cache_key branch August 30, 2013 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants