mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-31 01:11:25 +00:00
apc caching
This commit is contained in:
parent
77e64f99ad
commit
757211db74
1 changed files with 17 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue