From 757211db74a9e67468e33c6f43ae8afcda23ff6b Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Fri, 2 Sep 2016 17:30:27 -0400 Subject: [PATCH] apc caching --- lib/tools/Prefinery.class.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/tools/Prefinery.class.php b/lib/tools/Prefinery.class.php index de135823..7d990840 100644 --- a/lib/tools/Prefinery.class.php +++ b/lib/tools/Prefinery.class.php @@ -21,13 +21,29 @@ class Prefinery ]; - public static function findUser($emailOrId) + public static function findUser($emailOrId, $useApc = true) { + $apcEnabled = extension_loaded('apc') && ini_get('apc.enabled'); + if ($useApc && $apcEnabled) + { + $cached = apc_fetch('prefinery-user-'.$emailOrId, $success); + if ($success) + { + return $cached; + } + } + $user = is_numeric($emailOrId) ? Prefinery::findTesterById($emailOrId) : Prefinery::findTesterByEmail($emailOrId); if ($user) { unset($user['invitation_code']); // so we dont leak it } + + if ($useApc && $apcEnabled) + { + apc_store('prefinery-user-'.$emailOrId, $user, 3600); + } + return $user; }