add caching of users by username to improve performance
parent
3646a66168
commit
66a8d3876d
|
@ -49,6 +49,7 @@ if ( ! $result ) return;
|
||||||
$current_session = $_SESSION;
|
$current_session = $_SESSION;
|
||||||
zm_session_start();
|
zm_session_start();
|
||||||
|
|
||||||
|
$user_cache = array();
|
||||||
while ( $row = $result->fetch(PDO::FETCH_ASSOC) ) {
|
while ( $row = $result->fetch(PDO::FETCH_ASSOC) ) {
|
||||||
$_SESSION = array();
|
$_SESSION = array();
|
||||||
if ( ! session_decode($row['data']) ) {
|
if ( ! session_decode($row['data']) ) {
|
||||||
|
@ -63,10 +64,15 @@ while ( $row = $result->fetch(PDO::FETCH_ASSOC) ) {
|
||||||
# Not logged in
|
# Not logged in
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$user = ZM\User::find_one(array('Username'=>$_SESSION['username']));
|
if ( isset($user_cache[$_SESSION['username']]) ) {
|
||||||
if ( ! $user ) {
|
$user = $user_cache[$_SESSION['username']];
|
||||||
ZM\Logger::Debug('User not found for ' . $_SESSION['username']);
|
} else {
|
||||||
continue;
|
$user = ZM\User::find_one(array('Username'=>$_SESSION['username']));
|
||||||
|
if ( ! $user ) {
|
||||||
|
ZM\Logger::Debug('User not found for ' . $_SESSION['username']);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$user_cache[$_SESSION['username']] = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
|
|
Loading…
Reference in New Issue