From 30b7023ca753ac76bc2492ed7469e077b122f973 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Sun, 26 Apr 2015 15:43:32 -0500 Subject: [PATCH] orm: Cache table inspected fields in APC --- include/class.orm.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/include/class.orm.php b/include/class.orm.php index 75078e272..818d33be9 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -141,7 +141,20 @@ class ModelMeta implements ArrayAccess { } function inspectFields() { - return DbEngine::getCompiler()->inspectTable($this['table']); + static $cache; + if (!isset($cache)) + $cache = function_exists('apc_fetch'); + if ($cache) { + $key = md5(SECRET_SALT . GIT_VERSION . $this['table']); + if ($fields = apc_fetch($key)) { + return $fields; + } + } + $fields = DbEngine::getCompiler()->inspectTable($this['table']); + if ($cache) { + apc_store($key, $fields); + } + return $fields; } } -- GitLab