Version 5.0.0 beta 9

This commit is contained in:
Neo committed 2025-12-19 17:47:00 -08:00
1 parent 214f649f1d
commit 56979f8ee8
202 files changed
+4403 -1123

No files matched your search

+25 -19
View File
@@ -325,6 +325,11 @@ class Redis extends Store
* Redis key
*/
protected int $fetchAttempt = 0;
/**
* @var array|null cache online user data after fetching it
*/
protected ?array $onlineUsers = null;
/**
* Fetch all online users (but not spiders)
@@ -338,19 +343,20 @@ class Redis extends Store
*/
public function getOnlineUsers( int $flags=0, string $sort='desc', array $limit=NULL, int $memberGroup=NULL, bool $showAnonymous=FALSE ): array|int
{
try
if( $this->onlineUsers === NULL )
{
$results = RedisClass::i()->lRange( static::_key( 'session_onlinelist' ), 0, -1 );
}
catch ( RedisException $e )
{
/* Something went wrong, so reset the key to force a new file */
static::resetKey();
$results = NULL;
try
{
$this->onlineUsers = RedisClass::i()->lRange( static::_key( 'session_onlinelist' ), 0, -1 );
}
catch ( RedisException $e )
{
/* Something went wrong, so reset the key to force a new file */
static::resetKey();
}
}
if ( ! $results )
if ( !$this->onlineUsers )
{
/* Ensure file is deleted */
try
@@ -383,10 +389,10 @@ class Redis extends Store
try
{
/* Force expiration in 30 seconds to prevent stale caches hanging around */
RedisClass::i()->expire( static::_key( 'session_onlinelist' ), 30 );
$results = RedisClass::i()->lRange( static::_key( 'session_onlinelist' ), 0, -1 );
/* Force expiration in 60 seconds to prevent stale caches hanging around */
RedisClass::i()->expire( static::_key( 'session_onlinelist' ), 60 );
$this->onlineUsers = RedisClass::i()->lRange( static::_key( 'session_onlinelist' ), 0, -1 );
}
catch ( RedisException $e )
{
@@ -402,7 +408,7 @@ class Redis extends Store
}
else
{
$results = array();
$this->onlineUsers = [];
}
}
}
@@ -414,7 +420,7 @@ class Redis extends Store
$return = array();
$i = 0;
while( $i < count( $results ) )
while( $i < count( $this->onlineUsers ) )
{
$fields = array();
$data = NULL;
@@ -424,7 +430,7 @@ class Redis extends Store
{
try
{
$data = RedisClass::i()->decode( $results[ $i++ ] );
$data = RedisClass::i()->decode( $this->onlineUsers[ $i++ ] );
}
catch( RedisException $e )
{
@@ -434,11 +440,11 @@ class Redis extends Store
/* login_type must be cast as an integer or else anonymous state can be lost when adjustSessions() runs */
elseif( $field === 'login_type' )
{
$fields[ $field ] = (int) $results[ $i++ ];
$fields[ $field ] = (int) $this->onlineUsers[ $i++ ];
}
else
{
$fields[ $field ] = $results[ $i++ ];
$fields[ $field ] = $this->onlineUsers[ $i++ ];
}
}