From d9e02a5d0c1a81925df33a9b25501fc90db91451 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 16 Dec 2008 04:29:00 +0000 Subject: Various optimizations: o Add model_cache::get() which caches models avoiding duplicate lookups o Stop using ORM relationships for Item_Model::owner so that we can use caching o For Item_Model::xxx_edit fields, don't make them editable for guests o Other minor stuff. These optimizations reduce the number of queries for a 9-photos page from ~200 to ~45. Still way too many! --- core/helpers/model_cache.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 core/helpers/model_cache.php (limited to 'core/helpers/model_cache.php') diff --git a/core/helpers/model_cache.php b/core/helpers/model_cache.php new file mode 100644 index 00000000..7a01393b --- /dev/null +++ b/core/helpers/model_cache.php @@ -0,0 +1,35 @@ +$model_name->$field_name->$id)) { + $model = ORM::factory($model_name)->where($field_name, $id)->find(); + if (!$model->loaded) { + throw new Exception("@todo MISSING_MODEL $model_name:$id"); + } + self::$cache->$model_name->$field_name->$id = $model; + } + + + return self::$cache->$model_name->$field_name->$id; + } +} -- cgit v1.2.3