Example #1
0
 public function test5Action()
 {
     $redis = new RedisCluster();
     $redis->connect(array('host' => '127.0.0.1', 'port' => 6379));
     //*
     $cron_id = 10001;
     $CRON_KEY = 'CRON_LIST';
     //
     $PHONE_KEY = 'PHONE_LIST:' . $cron_id;
     //
     //cron info
     $cron = $redis->hget($CRON_KEY, $cron_id);
     if (empty($cron)) {
         $cron = array('id' => 10, 'name' => 'jackluo');
         //mysql data
         $redis->hset($CRON_KEY, $cron_id, $cron);
         // set redis
     }
     var_dump($cron);
     //phone list
     $phone_list = $redis->lrange($PHONE_KEY, 0, -1);
     if (empty($phone_list)) {
         $phone_list = explode(',', '13228191831,18608041585');
         //mysql data
         //join  list
         if ($phone_list) {
             $redis->multi();
             foreach ($phone_list as $phone) {
                 $redis->lpush($PHONE_KEY, $phone);
             }
             $redis->exec();
         }
     }
     var_dump($phone_list);
     die;
 }
Example #2
0
$redis = new RedisCluster();
$redis->connect(array('host' => '127.0.0.1', 'port' => 6379));
//*
$cron_id = 10001;
$CRON_KEY = 'CRON_LIST';
$PHONE_KEY = 'PHONE_LIST:' . $cron_id;
// cron info
$cron = $redis->hget($CRON_KEY, $cron_id);
if (empty($cron)) {
    $cron = array('id' => 10, 'name' => 'jackluo');
    // mysql data
    $redis->hset($CRON_KEY, $cron_id, $cron);
    // set redis
}
// phone list
$phone_list = $redis->lrange($PHONE_KEY, 0, -1);
print_r($phone_list);
echo "<br />";
if (empty($phone_list)) {
    $phone_list = explode(',', '13228191831, 18608041585');
    // mysql data
    // join list
    if ($phone_list) {
        $redis->multi();
        foreach ($phone_list as $phone) {
            $redis->lpush($PHONE_KEY, $phone);
        }
        $redis->exec();
    }
}
print_r($phone_list);