当前位置: 首页>>代码示例>>PHP>>正文


PHP Redis::setOption方法代码示例

本文整理汇总了PHP中Redis::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Redis::setOption方法的具体用法?PHP Redis::setOption怎么用?PHP Redis::setOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Redis的用法示例。


在下文中一共展示了Redis::setOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: clear

 public function clear($prefix = '')
 {
     $prefix = $this->getNamespace() . $prefix . '*';
     $it = null;
     self::$cache->setOption(\Redis::OPT_SCAN, \Redis::SCAN_RETRY);
     while ($keys = self::$cache->scan($it, $prefix)) {
         self::$cache->delete($keys);
     }
     return true;
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:10,代码来源:redis.php

示例2: initializeCAS

 private function initializeCAS()
 {
     $casClient = new \CAS_Client(CAS_VERSION_2_0, true, Config::get('cas.hostname'), Config::get('cas.port'), Config::get('cas.context'));
     $casClient->setNoCasServerValidation();
     if (true === Config::get('pgtservice.enabled', false)) {
         $casClient->setCallbackURL(Config::get('pgtservice.callback'));
         $casClient->setPGTStorage(new ProxyTicketServiceStorage($casClient));
     } else {
         if (false !== Config::get('redis.hostname', false)) {
             $casClient->setCallbackURL($this->url->getURL() . '/callback.php');
             $redis = new \Redis();
             $redis->connect(Config::get('redis.hostname'), Config::get('redis.port', 6379), 2, null, 100);
             $redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);
             $redis->setOption(\Redis::OPT_PREFIX, Config::get('application.project_name') . ':PHPCAS_TICKET_STORAGE:');
             $redis->select((int) Config::get('redis.hostname', 2));
             $casClient->setPGTStorage(new RedisTicketStorage($casClient, $redis));
         } else {
             $casClient->setCallbackURL($this->url->getURL() . '/callback.php');
             $casClient->setPGTStorageFile(session_save_path());
             // Handle logout requests but do not validate the server
             $casClient->handleLogoutRequests(false);
         }
     }
     // Accept all proxy chains
     $casClient->getAllowedProxyChains()->allowProxyChain(new \CAS_ProxyChain_Any());
     return $casClient;
 }
开发者ID:GlobalTechnology,项目名称:mpd-dashboard-app,代码行数:27,代码来源:ApplicationWrapper.php

示例3: __construct

 /**
  * Constructor.
  *
  * @param string $uniqId to be used to separate objects in addition to their key identifiers, for instance in a
  * multi-user scenario.
  *
  * @return \iveeCrest\RedisWrapper
  */
 public function __construct($uniqId)
 {
     $this->redis = new \Redis();
     $this->redis->connect(Config::getCacheHost(), Config::getCachePort());
     $this->redis->setOption(\Redis::OPT_PREFIX, Config::getCachePrefix());
     $this->uniqId = $uniqId;
 }
开发者ID:plugh3,项目名称:eve-trade1-perl,代码行数:15,代码来源:RedisWrapper.php

示例4: __construct

 /**
  * @param string $host redis server host
  * @param int $port redis server port
  * @param int $database redis server database num
  * @param string $channel redis queue key
  * @param string $prefix prefix of redis queue key
  */
 public function __construct($host = '127.0.0.1', $port = 6379, $database = 0, $channel = 'cache', $prefix = 'simple-fork-')
 {
     $this->redis = new \Redis();
     $connection_result = $this->redis->connect($host, $port);
     if (!$connection_result) {
         throw new \RuntimeException('can not connect to the redis server');
     }
     if ($database != 0) {
         $select_result = $this->redis->select($database);
         if (!$select_result) {
             throw new \RuntimeException('can not select the database');
         }
     }
     if (empty($channel)) {
         throw new \InvalidArgumentException('channel can not be empty');
     }
     $this->channel = $channel;
     if (empty($prefix)) {
         return;
     }
     $set_option_result = $this->redis->setOption(\Redis::OPT_PREFIX, $prefix);
     if (!$set_option_result) {
         throw new \RuntimeException('can not set the \\Redis::OPT_PREFIX Option');
     }
 }
开发者ID:huyanping,项目名称:simple-fork-php,代码行数:32,代码来源:RedisQueue.php

示例5: init

 function init()
 {
     list($ip, $port) = explode(':', $this->_defaults['server']);
     $this->_handler = new Redis();
     $this->_handler->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);
     $this->_handler->connect($ip, $port);
 }
开发者ID:revolveweb,项目名称:ppi-framework,代码行数:7,代码来源:Redis.php

示例6: init

 /**
  * @return void
  */
 protected function init()
 {
     $this->prefix = sprintf("%s#", base64_encode($this->identifier));
     $this->client = new \Redis();
     call_user_func_array([$this->client, 'connect'], func_get_args());
     $this->client->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);
     $this->client->setOption(\Redis::OPT_PREFIX, $this->prefix);
 }
开发者ID:alexanderc,项目名称:threadator,代码行数:11,代码来源:Redis.php

示例7: autoInit

 /**
  * If you want to use your own instance of Redis then pass it to UaiCachePhpredis::$redis before calling UserAgentInfoPeer for the first time.
  */
 public static function autoInit()
 {
     if (self::$redis instanceof Redis) {
         return;
     }
     self::$redis = new Redis();
     self::$redis->pconnect('127.0.0.1');
     self::$redis->setOption(Redis::OPT_SERIALIZER, UserAgentInfoConfig::CACHE_USE_IGBINARY ? Redis::SERIALIZER_IGBINARY : Redis::SERIALIZER_PHP);
 }
开发者ID:razzbee,项目名称:UserAgentInfo,代码行数:12,代码来源:UaiCachePhpredis.class.php

示例8: __construct

 public function __construct($connectionOrHost, $port = 6379)
 {
     if ($connectionOrHost instanceof \Redis) {
         $this->connection = $connectionOrHost;
     } else {
         $this->connection = new \Redis();
         $this->connection->connect($connectionOrHost, $port);
         $this->connection->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_PHP);
     }
 }
开发者ID:digitalcreations,项目名称:cache-phpredis,代码行数:10,代码来源:Cache.php

示例9: register

 public function register(Container $pimple)
 {
     $pimple['redis'] = function () use($pimple) {
         $redis = new \Redis();
         $options = $pimple['redis.options'];
         $redis->connect($options['host'], $options['port'], $options['timeout']);
         $redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_NONE);
         $redis->setOption(\Redis::OPT_PREFIX, $options['dbname'] . ':');
         $redis->auth($options['password']);
         return $redis;
     };
 }
开发者ID:bananos,项目名称:kanban,代码行数:12,代码来源:RedisServiceProvider.php

示例10: _connect

 protected function _connect()
 {
     $this->_redis = new \Redis();
     if ($this->_config['persistent']) {
         $this->_redis->pconnect($this->_config['host'], isset($this->_config['port']) ? $this->_config['port'] : null, isset($this->_config['timeout']) ? $this->_config['timeout'] : null);
     } else {
         $this->_redis->connect($this->_config['host'], isset($this->_config['port']) ? $this->_config['port'] : null, isset($this->_config['timeout']) ? $this->_config['timeout'] : null);
     }
     $this->_redis->setOption(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_NONE);
     if ($this->_config['database'] > 0) {
         $this->_redis->select($this->_config['database']);
     }
 }
开发者ID:bjlzt,项目名称:EasyRedis,代码行数:13,代码来源:Manager.php

示例11: getInstance

 /**
  * @return \Redis
  */
 public function getInstance()
 {
     if (is_null($this->instance)) {
         $this->instance = new \Redis();
         $this->instance->connect('localhost');
         /**
          * Without it doesn't work with array type
          */
         $serializer = defined('Redis::SERIALIZER_IGBINARY') ? \Redis::SERIALIZER_IGBINARY : \Redis::SERIALIZER_PHP;
         $this->instance->setOption(\Redis::OPT_SERIALIZER, $serializer);
         return $this->instance;
     }
     return $this->instance;
 }
开发者ID:ovr,项目名称:cacher,代码行数:17,代码来源:Redis.php

示例12: getRedis

 /**
  * @return \Redis
  * @throws InvalidConfigException
  */
 public function getRedis()
 {
     if (null === $this->instance) {
         if (!extension_loaded('redis')) {
             throw new InvalidConfigException(__CLASS__ . ' requires PHP `redis` extension to be loaded.');
         }
         $this->instance = new \Redis();
         if (!empty($this->options)) {
             foreach ($this->options as $key => $value) {
                 $this->instance->setOption($key, $value);
             }
         }
     }
     return $this->instance;
 }
开发者ID:hitmeister,项目名称:rapido-cache,代码行数:19,代码来源:RedisCache.php

示例13: getClient

 /**
  * Gets the redis client
  * @return Redis the redis client
  */
 public function getClient()
 {
     if ($this->_client === null) {
         $this->_client = new Redis();
         $this->_client->connect($this->hostname, $this->port);
         if (isset($this->password)) {
             if ($this->_client->auth($this->password) === false) {
                 throw new CException('Redis authentication failed!');
             }
         }
         $this->_client->setOption(Redis::OPT_PREFIX, $this->prefix);
         $this->_client->select($this->database);
     }
     return $this->_client;
 }
开发者ID:CrystReal,项目名称:Site_frontend,代码行数:19,代码来源:ARedisConnection.php

示例14: subscribe

 /**
  * @param string|string[] $channels
  * @param Closure         $callback
  */
 public function subscribe($channels, Closure $callback)
 {
     $channels = (array) $channels;
     $this->_subscribeCallback = $callback;
     $this->_redis->setOption(Redis::OPT_READ_TIMEOUT, 86400 * 100);
     $this->_redis->subscribe($channels, array($this, '_subscribeCallback'));
 }
开发者ID:aladin1394,项目名称:CM,代码行数:11,代码来源:Client.php

示例15: __construct

 /**
  * Constructs the redis Kohana_Cache object
  *
  * @param   array     configuration
  * @throws  Kohana_Cache_Exception
  */
 protected function __construct(array $config)
 {
     if (!extension_loaded('redis')) {
         throw new Cache_Exception('PHP redis extension is not available.');
     }
     parent::__construct($config);
     $host = isset($config['host']) ? $config['host'] : $this->_default_config['host'];
     $port = isset($config['port']) ? $config['port'] : $this->_default_config['port'];
     $this->_redis = new Redis();
     $this->_redis->connect($host, $port, 1);
     if (@$config['igbinary_serialize'] === true) {
         $this->_redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY);
     }
     $db_num = isset($config['db_num']) ? $config['db_num'] : $this->_default_config['db_num'];
     $this->_redis->select($db_num);
 }
开发者ID:sttt,项目名称:phpredis-kohana3.3,代码行数:22,代码来源:Redis.php


注:本文中的Redis::setOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。