Ruby on Rails - sql caching in ruby on rails- ruby on rails tutorial - rails guides - rails tutorial - ruby rails
SQL Caching
- Query caching is a Rails feature that caches the result set returned by each query.
- Rails encounters the same query again for that request, it will use the cached result set as opposed to running the query against the database again.
- For example:
The second time the same query is run against the database, it's not actually going to hit the database. The first time the result is returned from the query it is stored in the query cache and the second time it's pulled from memory. It's important to note that query caches are created at the start of an action and destroyed at the end of that action and thus persist only for the duration of the action. If you'd like to store query results in a more persistent fashion, you can with low level caching.