コード例 #1
12
ファイル: Client.php プロジェクト: cargomedia/cm
 /**
  * @param int $database
  * @throws CM_Exception
  */
 protected function _select($database)
 {
     $database = (int) $database;
     if ('OK' !== $this->_redis->select($database)) {
         throw new CM_Exception('Cannot select database.', null, ['database' => $database]);
     }
 }
コード例 #2
1
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     if (\Auth::check() == false) {
         return redirect('/auth/login');
     }
     // 一页多少文章
     $pageNum = 8;
     $userInfo = \Auth::user();
     $data = array();
     $data['articles'] = \App\Article::latest()->get();
     $data['userInfo'] = $userInfo;
     $dataArticles = array();
     $cacheKey = 'laravel:articles:index';
     $redis = new \Predis\Client(array('host' => '127.0.0.1', 'port' => 6379));
     $dataArticles = $redis->get($cacheKey);
     if (!$dataArticles || true) {
         //$dataArticles = \App\Article::latest()->take($pageNum)->with('content')->get()->toArray();
         $dataArticles = \App\Article::latest()->with('content')->paginate($pageNum)->toArray();
         //             var_dump($dataArticles);exit();
         $redis->setex($cacheKey, 3600 * 12, serialize($dataArticles));
     } else {
         $dataArticles = unserialize($dataArticles);
     }
     $data['articles'] = $dataArticles;
     //var_dump($data);exit();
     // $articleArr[0]['relations']['content']['content']
     return view('articles.admin.articleList')->with('data', $data);
 }
コード例 #3
1
ファイル: huichao.php プロジェクト: eddy8/MT4-Member-System
 /**
  * 保存记录至redis
  * @access private
  * @param  string $value 保存值
  * @return boolean       成功返回true,失败返回false
  */
 private function save_item_in_redis($value = '')
 {
     require './include/Predis/Autoloader.php';
     Predis\Autoloader::register();
     try {
         $r = new Predis\Client();
         $r->connect('127.0.0.1', 6379);
         $my_log_len = $r->llen($this->config->item('encryption_key'));
         if ($my_log_len < 21) {
             $r->rpush($this->config->item('encryption_key'), $value);
         } else {
             $r->lpop($this->config->item('encryption_key'));
             $r->rpush($this->config->item('encryption_key'), $value);
         }
         return TRUE;
     } catch (Exception $e) {
         echo $e->getMessage();
         return FALSE;
     }
 }
コード例 #4
0
ファイル: QueueHandler.php プロジェクト: indynagpal/MateCat
 /**
  * Lazy connection
  *
  * Get the connection to Redis server and return it
  *
  * @throws \Predis\Connection\ConnectionException
  */
 public function getRedisClient()
 {
     if (empty($this->redisHandler)) {
         $this->redisHandler = new RedisHandler();
     }
     return $this->redisHandler->getConnection();
 }
コード例 #5
0
ファイル: god_view.php プロジェクト: sdgdsffdsfff/jordan2
function getDataJson()
{
    if (isset($_GET['sfrom'])) {
        $jordanGUID = $_GET['jordanGUID'];
        $domain = $_GET['domain'];
        $protocol = $_GET['protocol'];
        $path = $_GET['path'];
        $location = $protocol . $domain . $path;
        $sfrom = $_GET['sfrom'];
        initConnection($db_config);
        //redis 使用
        require '../Predis/Autoloader.php';
        Predis\Autoloader::register();
        $redis = new Predis\Client(array('database' => '0', 'host' => '49.4.129.122', 'port' => 6379));
        $datestr = date("Y_m_d_H");
        $tableName = "request_" . $datestr;
        if ($redis->get("tableName") != $tableName) {
            create_request($tableName);
            $redis->set("tableName", $tableName);
        }
        $request_datetime = date('Y-m-d H:i:s', time());
        writeLog('../logs/' . $tableName . '.log', "{$jordanGUID}\t{$domain}\t{$location}\t{$request_datetime}\n", "a");
        insert_request_entry($jordanGUID, $domain, $location, $sfrom, $request_datetime, $tableName);
        insert_request_entry($jordanGUID, $domain, $location, $sfrom, $request_datetime, "request");
        //echo "success";
    } else {
        //echo "failure";
    }
}
コード例 #6
0
function getUrlInfo($url)
{
    $client = new \Predis\Client();
    $u = $client->get($url);
    if ($u == null) {
        $info = (object) [];
        $page = file_get_contents('https:' . $url);
        $xml = simplexml_load_string($page);
        $nodes = $xml->xpath("//ul/li[contains(@class, 'interlanguage-link')]/a");
        foreach ($nodes as $node) {
            $info->{$node['lang']} = (string) $node['href'];
        }
        /*
        	Sometimes pages have not a self-reference in interlanguage links,
        	here we enforce it to keep consistency
        */
        preg_match('/^\\/\\/(?<locale>[a-z\\-]*)\\.wikipedia\\.org\\/wiki\\/.*$/', $url, $matches);
        if (isset($matches['locale'])) {
            $info->{$matches['locale']} = $url;
        }
        $enc_info = json_encode($info);
        foreach ($info as $lang => $url) {
            $client->set($url, $enc_info);
        }
        return $info;
    } else {
        return json_decode($u);
    }
}
コード例 #7
0
ファイル: PacketProcessor.php プロジェクト: eventsd/eventsd
 public static function create_socket_server($host = "0.0.0.0", $port = 3465)
 {
     //Create a UDP socket
     if (!($sock = socket_create(AF_INET, SOCK_DGRAM, 0))) {
         $errorcode = socket_last_error();
         $errormsg = socket_strerror($errorcode);
         die("Couldn't create socket: [{$errorcode}] {$errormsg} \n");
     }
     echo "Socket created \n";
     // Bind the source address
     if (!socket_bind($sock, $host, $port)) {
         $errorcode = socket_last_error();
         $errormsg = socket_strerror($errorcode);
         die("Could not bind socket : [{$errorcode}] {$errormsg} \n");
     }
     echo "Socket bind OK \n";
     // Connect to Redis.
     $redis = new \Predis\Client();
     // Do some communication, this loop can handle multiple clients
     while (true) {
         //Receive some data
         $r = socket_recvfrom($sock, $buf, Eventsd::MaxUDPPacket, 0, $remote_ip, $remote_port);
         $redis->rpush('events_que', $buf);
         unset($event, $buf, $remote_ip, $remote_port);
     }
     socket_close($sock);
 }
コード例 #8
0
ファイル: RedisSetDriver.php プロジェクト: tomaj/hermes
 /**
  * {@inheritdoc}
  */
 public function wait(Closure $callback)
 {
     while (true) {
         if (!$this->shouldProcessNext()) {
             break;
         }
         while (true) {
             $messageString = false;
             if ($this->redis instanceof \Predis\Client) {
                 $messageString = $this->redis->spop($this->key);
             }
             if ($this->redis instanceof \Redis) {
                 $messageString = $this->redis->sPop($this->key);
             }
             if (!$messageString) {
                 break;
             }
             $callback($this->serializer->unserialize($messageString));
             $this->incrementProcessedItems();
         }
         if ($this->refreshInterval) {
             sleep($this->refreshInterval);
         }
     }
 }
コード例 #9
0
 protected function setUp()
 {
     $client = new \Predis\Client();
     $client->flushdb();
     $this->base_cache = new OffloadCacheRedis($client);
     $this->manager = new OffloadManager($this->base_cache, new OffloadLockRedis($client));
 }
コード例 #10
0
ファイル: SocketTest.php プロジェクト: rasodu/DLEMP
 /**
  *@depends testSubscribeSockerIOChannel
  */
 public function testEmitSocketIOMessage()
 {
     $this->sent_data = 'Random string:' . rand();
     $redis = new Predis\Client('tcp://redis:6379');
     $publish = json_encode(['event' => $this->event_name, 'data' => $this->sent_data]);
     $result = $redis->publish($this->channel_name, $publish);
     $this->assertSame(1, $result);
 }
コード例 #11
0
function get_endpoints_from_redis_for_blog($blog_id)
{
    $key = 'site_id:' . $blog_id . ':webhooks';
    $redis = new Predis\Client(['scheme' => 'tcp', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'password' => REDIS_PASSWORD]);
    $endpoints = json_decode($redis->get($key), true);
    if (!is_array($endpoints)) {
        return array();
    }
    return $endpoints;
}
コード例 #12
0
 /**
  * Set up dependencies
  */
 public function setUp()
 {
     parent::setUp();
     $configurationManager = $this->objectManager->get('TYPO3\\Flow\\Configuration\\ConfigurationManager');
     $settings = $configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Jobqueue.Redis');
     if (!isset($settings['testing']['enabled']) || $settings['testing']['enabled'] !== TRUE) {
         $this->markTestSkipped('Test database is not configured');
     }
     $this->queue = new \Admaykin\Jobqueue\Redis\Queue\RedisQueue('Test queue', $settings['testing']);
     $client = new \Predis\Client($settings['testing']['client']);
     $client->flushdb();
 }
コード例 #13
0
function redis_session_destroy($id) {
  global $redisServer, $redisTargetPrefix;

  $redisConnection = new \Predis\Client($redisServer);
  $redisConnection->del($redisTargetPrefix . $id);

  $unpacked = $redisConnection->keys($redisTargetPrefix . $id . ":*");

  foreach ($unpacked as $unp) {
    $redisConnection->del($unp);
  }
}
コード例 #14
0
ファイル: common.php プロジェクト: eddy8/MT4-Member-System
 /**
  * 获取动态出入金、转账记录
  * @return mixed 成功返回对应记录,失败返回false
  */
 private function get_my_log()
 {
     require_once './include/Predis/Autoloader.php';
     Predis\Autoloader::register();
     try {
         $r = new Predis\Client();
         $r->connect('127.0.0.1', 6379);
         $my_log_len = $r->llen($this->config->item('encryption_key'));
         return $my_log_len == 0 ? false : $r->lrange($this->config->item('encryption_key'), 0, $my_log_len - 1);
     } catch (Exception $e) {
         return false;
     }
 }
コード例 #15
0
function redisLink() {
    global $redisHost, $redisKey;
    static $r = false;

    if ($r) return $r;
    if($redisHost && $redisKey) { // Host and Key loaded from Environment Variable
        $r = new Predis\Client($redisHost);
        $r->auth($redisKey);
    } else {
        $r = new Predis\Client();
    }
    return $r;
}
コード例 #16
0
ファイル: Redis.php プロジェクト: dcunited08/wurfl-api
 private function buildRedisObject($client, $host, $port, $database = 0)
 {
     if ($client == 'phpredis') {
         $redis = new Redis();
         $redis->connect($host, $port);
     } elseif ($client == 'predis') {
         $redis = new Predis\Client(array('scheme' => 'tcp', 'host' => $host, 'port' => $port));
         $redis->connect();
     }
     if ($database) {
         $redis->select($database);
     }
     return $redis;
 }
コード例 #17
0
ファイル: QueueHandler.php プロジェクト: spMohanty/MateCat
 /**
  * Lazy connection
  *
  * Get the connection to Redis server and return it
  *
  * @throws \Predis\Connection\ConnectionException
  */
 public function getRedisClient()
 {
     $resource = null;
     if ($this->redisHandler != null) {
         $reflectorClass = new ReflectionClass($this->redisHandler->getConnection());
         $reflectorProperty = $reflectorClass->getParentClass()->getProperty('resource');
         $reflectorProperty->setAccessible(true);
         $resource = $reflectorProperty->getValue($this->redisHandler->getConnection());
     }
     if ($this->redisHandler === null || !$this->redisHandler->getConnection()->isConnected() || !is_resource($resource)) {
         $this->redisHandler = new Predis\Client(INIT::$REDIS_SERVERS);
     }
     return $this->redisHandler;
 }
コード例 #18
0
ファイル: index.php プロジェクト: mendianchun/at
 /**
  * 完善daemon处理函数,此函数必备
  *
  *
  */
 function daemonFunc()
 {
     require dirname(__FILE__) . '/../../config/testUI/config.php';
     $redis = new Predis\Client($_config['redis_server']);
     $http = new Http();
     while ($this->subProcessCheck()) {
         //处理队列
         $case_data = $redis->lpop($_config['queue_name']);
         if (empty($case_data)) {
             break;
         } else {
             $arr = json_decode($case_data, true);
             $url = $arr['host'] . $arr['url'];
             $query = $arr['param'];
             $method = strtoupper($arr['method']);
             //拼装表单提交数据
             $formdata = array();
             $temp_arry = explode('&', $query);
             foreach ($temp_arry as $item) {
                 list($k, $v) = explode('=', $item);
                 $formdata[$k] = $v;
             }
             //判断是否需要token
             if (isset($arr['token'])) {
                 $formdata['token'] = $arr['token'];
             }
             if ($method == 'GET') {
                 $http->get($url, $formdata);
             } else {
                 $http->post($url, $formdata);
             }
             $res = $http->getContent();
             //此处增加返回结果的判断
             $result = $arr['result'];
             if ($result == $res) {
                 $res_test = 1;
             } else {
                 $res_test = 0;
             }
             //                $req['url'] = $url;
             //                $req['data'] = $formdata;
             //$result =array();
             file_put_contents(realpath(dirname(__FILE__)) . '/../../output/testUI.log', $res_test . '|' . $result . '|' . $res . '|' . $url . '|' . json_encode($formdata) . "\n", FILE_APPEND);
         }
         //增加处理数,不增加处理数,就需要子进程本身有退出机制。
         //$this->requestCount++;
         //释放时间片
         usleep(5000);
     }
 }
コード例 #19
0
 public function testGetApc()
 {
     $redis = new \Predis\Client(array("scheme" => "tcp", "host" => 'localhost', "port" => 6379));
     $client = new LDClient("BOGUS_API_KEY", array('feature_requester_class' => '\\LaunchDarkly\\ApcLDDFeatureRequester', 'apc_expiration' => 1));
     $builder = new LDUserBuilder(3);
     $user = $builder->build();
     $redis->del("launchdarkly:features");
     $this->assertEquals("jim", $client->toggle('foo', $user, 'jim'));
     $redis->hset("launchdarkly:features", 'foo', $this->gen_feature("foo", "bar"));
     $this->assertEquals("bar", $client->toggle('foo', $user, 'jim'));
     # cached value so not updated
     $redis->hset("launchdarkly:features", 'foo', $this->gen_feature("foo", "baz"));
     $this->assertEquals("bar", $client->toggle('foo', $user, 'jim'));
     apc_delete("launchdarkly:features.foo");
     $this->assertEquals("baz", $client->toggle('foo', $user, 'jim'));
 }
コード例 #20
0
ファイル: Predisql.php プロジェクト: JakSprats/predis
 public function __construct($db_conn = null, $parameters = null, $clientOptions = null)
 {
     parent::__construct($parameters, $clientOptions);
     $this->mysql_db = $db_conn;
     $this->echo_command = 0;
     $this->echo_response = 0;
     $this->mysql_echo_command = 0;
 }
コード例 #21
0
ファイル: AbstractDao.php プロジェクト: spMohanty/MateCat
 /**
  * @param $query
  *
  * @return bool
  */
 protected function _destroyCache($query)
 {
     $this->_cacheSetConnection();
     if (isset($this->cache_con) && !empty($this->cache_con)) {
         return $this->cache_con->delete($query);
     }
     return false;
 }
コード例 #22
0
ファイル: SeatQueueStatus.php プロジェクト: boweiliu/seat
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     // Connect to the Redis backend using Predis
     $redis = new \Predis\Client(array('host' => \Config::get('database.redis.default.host'), 'port' => \Config::get('database.redis.default.port')));
     // Count the amount of jobs in the queue by
     // issuing a Redis LRANGE command:
     //
     // http://redis.io/commands/LRANGE
     $redis_count = count($redis->lrange('queues:default', 0, -1));
     $this->line('Redis reports ' . $redis_count . ' jobs in the queue (queues:default)');
     // Get the Queued job count from the database
     $db_info = \SeatQueueInformation::where('status', '=', 'Queued')->count();
     $this->line('The database reports ' . $db_info . ' queued jobs');
     // If the amount of jobs in the redis queue does
     // not match that of the database, just warn
     // about this.
     if ($db_info != $redis_count) {
         $this->info('[!] The redis & db queued counts are not the same. This is not always a bad thing');
     }
     // Get the Done job count frmo the database
     $db_info = \SeatQueueInformation::where('status', '=', 'Done')->count();
     $this->line('The database reports ' . $db_info . ' done jobs');
     // Get the Error job count from the database
     $db_info = \SeatQueueInformation::where('status', '=', 'Error')->count();
     // If there are Error jobs, loop over them and
     // print the status details
     if ($db_info > 0) {
         $this->comment('Current error-state jobs (' . $db_info . '):');
         foreach (\SeatQueueInformation::where('status', '=', 'Error')->get() as $row) {
             $this->line('OwnerID: ' . $row->ownerID . ' | Scope: ' . $row->scope . ' | API: ' . $row->api . ' | Status: "' . str_limit($row->output, 20, '...') . '" | Created: ' . Carbon::parse($row->created_at)->diffForHumans() . ' | Last updated: ' . Carbon::parse($row->updated_at)->diffForHumans());
         }
     } else {
         $this->line('The database reports ' . $db_info . ' error jobs');
     }
     // Get the Working jobs from the database
     $db_info = \SeatQueueInformation::where('status', '=', 'Working')->count();
     if ($db_info > 0) {
         $this->comment('Current working-state jobs (' . $db_info . '):');
         foreach (\SeatQueueInformation::where('status', '=', 'Working')->get() as $row) {
             $this->line('OwnerID: ' . $row->ownerID . ' | Scope: ' . $row->scope . ' | API: ' . $row->api . ' | Status: "' . $row->output . '" | Created: ' . Carbon::parse($row->created_at)->diffForHumans() . ' | Last updated: ' . Carbon::parse($row->updated_at)->diffForHumans());
         }
     } else {
         $this->line('The database reports ' . $db_info . ' working jobs');
     }
 }
コード例 #23
0
 /**
  * Store a key/value pair in the cache
  * @param $key string The key to store as
  * @param $value object The value to store
  * @param $expire int The number of seconds to expire in, 0 for forever
  * @return TRUE on success and FALSE on failure
  */
 public function set($key, $value, $expire = 0)
 {
     if (!$this->isEnabled()) {
         return false;
     }
     if (!$this->attemptedConnection) {
         $this->connect();
     }
     // Check for flags
     if ($expire == CACHE_UNTIL_NEXT_GRAPH) {
         $expire = strtotime('+30 minutes', getLastGraphEpoch());
     }
     $this->handle->set($key, gzencode($value));
     if ($expire > 0) {
         $this->handle->expireat($key, $expire);
     }
     return true;
 }
コード例 #24
0
 public function index()
 {
     \Predis\Autoloader::register();
     $redis = new \Predis\Client();
     $feedList = M('Feed')->alias('f')->field('f.feedid,f.posttime,f.show,f.content,f.picpath,f.appid,u.avator,u.nickname')->join(array('__USERS__ AS u ON f.userid =  u.userid '))->where('f.userid = ' . ACPopedom::getID())->select();
     foreach ($feedList as $key => $value) {
         $feedList[$key]['posttime'] = beforeTime($value['posttime']);
         if ($value['picpath']) {
             $feedList[$key]['picpath'] = explode('#$', $value['picpath']);
             $feedList[$key]['pic-col'] = count($feedList[$key]['picpath']) > 4 ? 3 : 12 / count($feedList[$key]['picpath']);
         }
         //取出点赞数
         $praise = $redis->hget('feed:' . $value['feedid'], 'praise');
         $feedList[$key]['praise'] = $praise ? $praise : 0;
     }
     //var_dump($feedList);
     $this->assign('feedlist', $feedList);
     $this->assign('userinfo', ACPopedom::getUserInfo());
     $this->display();
 }
コード例 #25
0
 /**
  * 点赞一条feed
  */
 public function praise()
 {
     $feedid = intval(I('post.feedid', ''));
     \Predis\Autoloader::register();
     $redis = new \Predis\Client();
     if ($redis->zscore('feed:' . $feedid . ':praise', ACPopedom::getID())) {
         $res = $redis->zrem('feed:' . $feedid . ':praise', ACPopedom::getID());
         $rs = $redis->hincrby('feed:' . $feedid, 'praise', -1);
         $this->ajaxReturn($res && $rs ? array('status' => true) : array('status' => false, 'message' => '由于服务器君罢工,取消点赞失败失败啦..'));
     } else {
         $rs = $redis->zadd('feed:' . $feedid . ':praise', time(), ACPopedom::getID());
         $result = $redis->hincrby('feed:' . $feedid, 'praise', 1);
         $this->ajaxReturn($result && $rs ? array('status' => true, 'message' => '点赞成功了,么么哒') : array('status' => false, 'message' => '由于服务器君罢工,点赞失败失败啦..'));
     }
 }
コード例 #26
0
    table.insert(hashes, redis.call('hgetall', key))
end
return hashes
LUA;
    public function getScript()
    {
        return self::BODY;
    }
}
// ------------------------------------------------------------------------- //
$parameters = array('tcp://127.0.0.1:6379/?alias=master', 'tcp://127.0.0.1:6380/?alias=slave');
$options = array('profile' => function ($options, $option) {
    $profile = $options->getDefault($option);
    $profile->defineCommand('hmgetall', 'HashMultipleGetAll');
    return $profile;
}, 'replication' => function () {
    $strategy = new ReplicationStrategy();
    $strategy->setScriptReadOnly(HashMultipleGetAll::BODY);
    $replication = new MasterSlaveReplication($strategy);
    return $replication;
});
// ------------------------------------------------------------------------- //
$client = new Predis\Client($parameters, $options);
// Execute the following commands on the master server using redis-cli:
// $ ./redis-cli HMSET metavars foo bar hoge piyo
// $ ./redis-cli HMSET servers master host1 slave host2
$hashes = $client->hmgetall('metavars', 'servers');
$replication = $client->getConnection();
$stillOnSlave = $replication->getCurrent() === $replication->getConnectionById('slave');
echo "Is still on slave? ", $stillOnSlave ? 'YES!' : 'NO!', PHP_EOL;
var_export($hashes);
コード例 #27
0
<?php

/*
 * This file is part of the Predis package.
 *
 * (c) Daniele Alessandri <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require 'SharedConfigurations.php';
// redis can set keys and their relative values in one go
// using MSET, then the same values can be retrieved with
// a single command using MGET.
$mkv = array('usr:0001' => 'First user', 'usr:0002' => 'Second user', 'usr:0003' => 'Third user');
$client = new Predis\Client($single_server);
$client->mset($mkv);
$retval = $client->mget(array_keys($mkv));
print_r($retval);
/* OUTPUT:
Array
(
    [0] => First user
    [1] => Second user
    [2] => Third user
)
*/
コード例 #28
0
ファイル: render.php プロジェクト: dima056359/oselya
<?php

header('Content-Type: text/html; charset=utf-8', true);
error_reporting(E_ALL);
?>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:600,400,300&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/jquery-ui.min.css" rel="stylesheet">
    <link href="../css/custom.css" rel="stylesheet">
<?php 
require "predis/autoload.php";
Predis\Autoloader::register();
$redis = new Predis\Client();
/*  If uses external server

	$client = new Predis\Client([
	    'scheme' => 'tcp',
	    'host'   => '127.0.0.1',
	    'port'   => 6379,
	]);

*/
// Simplest demo how to use Redis
/*
$redis->set("hello_world", "Hi from php!");
$value = $redis->get("hello_world");
echo $value;
*/
// 123 - id of property
$redis->hmset("123", array("type" => "нерухомість поза містом", "name" => "Приватний будинок поза містом", "location" => "с. Ульянівка", "description" => "Приватний будинок поза містом. Приватизована земельна ділянка. Світло, вода, газ - присутні. Є місце для будівництва.", "sdelka" => "Продаж", "rooms" => 5, "floors" => 2, "area" => 90, "price" => "12000\$"));
コード例 #29
-1
 /**
  * Creates predis client
  * @param array $parameters
  * @return \Predis\Client
  */
 public function createClient(array $parameters = array())
 {
     $predisClient = new \Predis\Client($parameters);
     $predisClient->getProfile()->defineCommand('sentinel', '\\Redis\\Client\\Adapter\\Predis\\Command\\SentinelCommand');
     $predisClient->getProfile()->defineCommand('role', '\\Redis\\Client\\Adapter\\Predis\\Command\\RoleCommand');
     return $predisClient;
 }
コード例 #30
-2
 public function notifyUserNewMessage($params)
 {
     try {
         $client = new Predis\Client($this->settings['redis']);
         $client->publish('chat_room_' . $this->settings['instance_id'] . '_' . $params['chat']->id, $params['chat']->id);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }