mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-09-01 17:55:10 +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);
|
$user = is_numeric($emailOrId) ? Prefinery::findTesterById($emailOrId) : Prefinery::findTesterByEmail($emailOrId);
|
||||||
if ($user)
|
if ($user)
|
||||||
{
|
{
|
||||||
unset($user['invitation_code']); // so we dont leak it
|
unset($user['invitation_code']); // so we dont leak it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($useApc && $apcEnabled)
|
||||||
|
{
|
||||||
|
apc_store('prefinery-user-'.$emailOrId, $user, 3600);
|
||||||
|
}
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue