Esempio n. 1
1
 /**
  */
 protected function _exists($keys)
 {
     $pipeline = $this->_predis->pipeline();
     foreach ($keys as $val) {
         $pipeline->exists($val);
     }
     return array_combine($keys, $pipeline->execute());
 }
Esempio n. 2
0
 /**
  */
 protected function _exists($keys)
 {
     $pipeline = $this->_predis->pipeline();
     foreach ($keys as $val) {
         $pipeline->exists($val);
     }
     $exists = array();
     foreach ($pipeline->execute() as $key => $val) {
         $exists[$keys[$key]] = (bool) $val;
     }
     return $exists;
 }
function redis_session_write($id, $data) {
  global $unpackItems, $redisServer, $redisTargetPrefix;

  $redisConnection = new \Predis\Client($redisServer);
  $ttl = ini_get("session.gc_maxlifetime");
  
  $redisConnection->pipeline(function ($r) use (&$id, &$data, &$redisTargetPrefix, &$ttl, &$unpackItems) {
      $r->setex($redisTargetPrefix . $id, $ttl,
		base64_encode($data));

      foreach ($unpackItems as $item) {
	$keyname = $redisTargetPrefix . $id . ":" . $item;
	
	if (isset($_SESSION[$item])) {
	  $r->setex($keyname, $ttl, $_SESSION[$item]);
	  
	} else {
	  $r->del($keyname);
	}
      }
    });
}
Esempio n. 4
0
 * 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';
// When you have a whole set of consecutive commands to send to
// a redis server, you can use a pipeline to improve performances.
$client = new Predis\Client($single_server);
$replies = $client->pipeline(function ($pipe) {
    $pipe->ping();
    $pipe->flushdb();
    $pipe->incrby('counter', 10);
    $pipe->incrby('counter', 30);
    $pipe->exists('counter');
    $pipe->get('counter');
    $pipe->mget('does_not_exist', 'counter');
});
print_r($replies);
/* OUTPUT:
Array
(
    [0] => 1
    [1] => 1
    [2] => 10
    [3] => 40
    [4] => 1
    [5] => 40
    [6] => Array
<?php

require 'vendor/autoload.php';
Predis\Autoloader::register();
$client = new Predis\Client(array('host' => '127.0.0.1', 'port' => 6379), array('prefix' => 'php:'));
# fluent interface
$client->pipeline()->sadd("cards:suits", 'hearts')->sadd("cards:suits", 'spades')->sadd("cards:suits", 'diamonds')->sadd("cards:suits", 'clubs')->smembers("cards:suits")->execute();
# array(1,1,1,1, array('diamonds', 'hearts', 'clubs', 'spades'))
# anonymous function
$client->pipeline(function ($pipe) {
    $pipe->scard("cards:suits");
    $pipe->smembers("cards:suits");
});
# array(4, array('diamonds', 'hearts', 'clubs', 'spades'))