summaryrefslogtreecommitdiff
path: root/README.markdown
diff options
context:
space:
mode:
authorJamie Matthews <[email protected]>2011-01-08 13:05:13 +0000
committerJamie Matthews <[email protected]>2011-01-08 13:05:13 +0000
commit6fad05968483c255a5c768b1cabbab15a4dffc30 (patch)
tree204a8e225dcddb7d586e38d69e89ddbafd73d2d4 /README.markdown
parente351921f8bfe8d469cae644147ce037353ddcea7 (diff)
Add simple query caching - issue #11
Diffstat (limited to 'README.markdown')
-rw-r--r--README.markdown16
1 files changed, 16 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown
index 9a93ffa..995f46c 100644
--- a/README.markdown
+++ b/README.markdown
@@ -408,3 +408,19 @@ Setting: `logging`
Idiorm can log all queries it executes. To enable query logging, set the `logging` option to `true` (it is `false` by default).
When query logging is enabled, you can use two static methods to access the log. `ORM::get_last_query()` returns the most recent query executed. `ORM::get_query_log()` returns an array of all queries executed.
+
+#### Query caching ####
+
+Setting: `caching`
+
+Idiorm can cache the queries it executes during a request. To enable query caching, set the `caching` option to `true` (it is `false` by default).
+
+When query caching is enabled, Idiorm will cache the results of every `SELECT` query it executes. If Idiorm encounters a query that has already been run, it will fetch the results directly from its cache and not perform a database query.
+
+##### Warnings and gotchas #####
+
+* Note that this is an in-memory cache that only persists data for the duration of a single request. This is *not* a replacement for a persistent cache such as [Memcached](http://www.memcached.org/).
+
+* Idiorm's cache is very simple, and does not attempt to invalidate itself when data changes. This means that if you run a query to retrieve some data, modify and save it, and then run the same query again, the results will be stale (ie, they will not reflect your modifications). This could potentially cause subtle bugs in your application. If you have caching enabled and you are experiencing odd behaviour, disable it and try again. If you do need to perform such operations but still wish to use the cache, you can call the `ORM::clear_cache()` to clear all existing cached queries.
+
+* Enabling the cache will increase the memory usage of your application, as all database rows that are fetched during each request are held in memory. If you are working with large quantities of data, you may wish to disable the cache.