class PostsController < ApplicationController def index response_cache do @posts = @shop.posts.paginate(params[:page]) respond_with(@posts) end end def cache_key_data { shop_id: @shop.id, path: request.path, format: request.format, params: params.slice(:page), shop_version: @shop.version } end end
class Product < ActiveRecord::Base include IdentityCache cache_index :shop_id, :handle, :unique => true end Product.fetch_by_shop_id_and_handle(shop_id, handle)
class NewIndexOnOrders < ActiveRecord::Migration def self.up Lhm.change_table :orders do |m| m.add_index [:shop_id, :customer_id] end end def self.down # end end