No release in over 3 years
Low commit activity in last 3 years
An ActiveRecord extension for enabling SQL_CACHE and SQL_NO_CACHE in MySQL queries
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
>= 0
~> 10.0
>= 0

Runtime

>= 4.0
 Project Readme

Build Status

activerecord-mysql-sql-cache

An ActiveRecord extension for enabling SQL_CACHE and SQL_NO_CACHE in MySQL queries

Dependencies

Supported versions:

  • Ruby 1.9+
  • ActiveRecord 4.0+ (Arel 4.0+)

Installation

Add this line to your application's Gemfile:

gem 'activerecord-mysql-sql-cache'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activerecord-mysql-sql-cache

Usage

Methods that #sql_cache and #sql_no_cache are added into ActiveRecord::Relation.

class Product < ActiveRecord::Base
end

Product.where(id: 1).to_sql
# => SELECT `products`.`*` FROM `products` WHERE `id` = 1;

Product.where(id: 1).sql_cache.to_sql
# => SELECT SQL_CACHE `products`.`*` FROM `products` WHERE `id` = 1;

Product.where(id: 1).sql_no_cache.to_sql
# => SELECT SQL_NO_CACHE `products`.`*` FROM `products` WHERE `id` = 1;

#sql_cache accepts a boolean argument:

# default: true
Product.where(id: 1).sql_cache(true).to_sql
# => SELECT SQL_CACHE `products`.`*` FROM `products` WHERE `id` = 1;

Product.where(id: 1).sql_cache(false).to_sql
# => SELECT SQL_NO_CACHE `products`.`*` FROM `products` WHERE `id` = 1;

Product.where(id: 1).sql_cache(nil).to_sql
# => SELECT `products`.`*` FROM `products` WHERE `id` = 1;

License

Arproxy is released under the MIT license:

Copyright (c) 2015 Issei Naruta