From c522f28c7cf6c37ddd6b2b2a4bcc3093784f7577 Mon Sep 17 00:00:00 2001 From: icewing Date: Mon, 9 Jun 2008 12:40:45 +0000 Subject: Marcus Povey * Added caching to entities. Please report any problems. git-svn-id: https://code.elgg.org/elgg/trunk@831 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/sites.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'engine/lib/sites.php') diff --git a/engine/lib/sites.php b/engine/lib/sites.php index 9823f097a..89a95812e 100644 --- a/engine/lib/sites.php +++ b/engine/lib/sites.php @@ -212,8 +212,6 @@ */ public function getCollections($subtype="", $limit = 10, $offset = 0) { get_site_collections($this->getGUID(), $subtype, $limit, $offset); } - - } /** @@ -227,7 +225,23 @@ $guid = (int)$guid; - return get_data_row("SELECT * from {$CONFIG->dbprefix}sites_entity where guid=$guid"); + $row = retrieve_cached_entity_row($guid); + if ($row) + { + // We have already cached this object, so retrieve its value from the cache + if ($CONFIG->debug) + error_log("** Retrieving sub part of GUID:$guid from cache"); + + return $row; + } + else + { + // Object not cached, load it. + if ($CONFIG->debug) + error_log("** Sub part of GUID:$guid loaded from DB"); + + return get_data_row("SELECT * from {$CONFIG->dbprefix}sites_entity where guid=$guid"); + } } /** -- cgit v1.2.3