/**
* @desc Online time-length cache
* @var String
* @access Public
*/
Const Key_online_cache = ' Hd:online:cache ';
/**
* @desc Insert Hd_online_data table
* @access Public
* @param array $data data
* @return Boolean
*/
Public function Addcache (array $data)
{
if (empty ($data))
{
return;
}
$redis = $this->data[' Redis_main ');
$redis->hmset (Self::key_online_cache, $data);
return true;
}
/**
* @desc Query Hd_online_data form
* @access Public
* @param void
* @return Boolean
*/
Public Function GetCache ()
{
$redis = $this->data[' Redis_main ');
Return $redis->hgetall (Self::key_online_cache);
}
/**
* Timed Script Execution Area
* @access Public
* @param void
* @return void
*/
Public function Add ()
{
$data = $this->getcache ();
foreach ($data as $k = & $v)
{
$renum = $v [' datetime '];
if ($v [' Roomid '] > 1002)
{
$v [' num '] + = 5;
}
}
$data && Array_multisort ($renum, Sort_desc, Sort_numeric, $data);
$res = Array (' sign_id ' = = rand (23,555), ' client ' = ' PC ',
' Nickname ' = rand (999,9999), ' create_timeline ' = "date (' y-m-d h:i:s '),
' Last_timeline ' + date (' y-m-d h:i:s '), ' roomid ' = rand (1000,1005), ' datetime ' = Time (), ' num ' = 1);
Array_unshift ($data, $res);
$this->addcache ($data);
Print_r ($data);
}
Online time-Length caching