Skip to content

Instantly share code, notes, and snippets.

@jeremygottfried
Last active May 22, 2018 04:48
Show Gist options
  • Save jeremygottfried/a840ea9801f57da8c5b3629a6aaa1bde to your computer and use it in GitHub Desktop.
Save jeremygottfried/a840ea9801f57da8c5b3629a6aaa1bde to your computer and use it in GitHub Desktop.
#models/post.rb
class Post < ApplicationRecord
belongs_to :user, touch: true
after_save :create_json_cache
def self.cache_key(posts)
{
serializer: 'posts',
stat_record: posts.maximum(:updated_at)
}
end
private
def create_json_cache
CreatePostsJsonCacheJob.perform_later
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment