module MemberCleanCache extend ActiveSupport::Concern included do def destroy_cache if self.class==Page MemberIndexCache.where(page_id: self.id).destroy_all else MemberIndexCache.all.destroy_all end end after_save do self.destroy_cache end before_destroy do self.destroy_cache end end end