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/users.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'engine/lib/users.php') diff --git a/engine/lib/users.php b/engine/lib/users.php index 76d5cac00..795ec4415 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -244,7 +244,7 @@ */ function getFriends($subtype = "", $limit = 10, $offset = 0) { return get_user_friends($this->getGUID(), $subtype, $limit, $offset); } - /** + /** * Retrieves a list of people who have made this user a friend * * @param string $subtype Optionally, the subtype of user to filter to (leave blank for all) @@ -314,10 +314,26 @@ function get_user_entity_as_row($guid) { global $CONFIG; + + $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"); + + $guid = (int)$guid; - $guid = (int)$guid; - - return get_data_row("SELECT * from {$CONFIG->dbprefix}users_entity where guid=$guid"); + return get_data_row("SELECT * from {$CONFIG->dbprefix}users_entity where guid=$guid"); + } } /** -- cgit v1.2.3