在 http://www.redis.net.cn/ 能找到所有关于redis的信息,包括安装、命令、在编程语言中的使用等等。这里就不讲如何安装redis了,因为在上面的网站中都能找到。下面直接讲redis是如何在php中使用的。
安装phpredis扩展前需要下载phpredis扩展,下载前根据你本地php环境选择对应的phpreids扩展(选不对的话,就有可能无法使用redis了),建议使用php5.4.x版本环境。
extension=php_igbinary.dll
extension=php_redis.dll
1 $redis = new Redis(); 2 //连接redis服务器 3 $redis->connect(‘127.0.0.1‘, ‘6379‘); 4 5 6 $key = "key"; 7 $val = "val"; 8 9 //redis key操作 10 $redis->exists($key); //判断key值是否存在 11 $redis->expire($key, 10); //设置key在10秒后过期 12 13 //redis string 字符串 14 $redis->set($key, $val); 15 $redis->incr($key); //key值+1,除非val是整数,否则函数执行失败 16 $redis->decr($key); //key值-1,同上 17 $redis->append($key, "ue"); //追加key值内容 18 $redis->strlen($key); //返回key值的长度 19 20 //当第一次设置key值后,key值的数据类型就不能改变了。 21 $redis->del($key); //删除key值 22 23 //redis hash 哈希 24 $redis->hset($key, ‘field1‘, ‘val1‘); //设置一个key-value键值对 25 $redis->hmset($key, array(‘field2‘=>‘val2‘, ‘field3‘=>‘val3‘)); //设置多个k-v键值对 26 $redis->hget($key, ‘field2‘); //获取hash其中的一个键值 27 $redis->hmget($key, array(‘field2‘, ‘field1‘)); //获取hash的多个键值 28 $redis->hgetall($key); //获取hash中所有的键值对 29 $redis->hlen($key); //获取hash中键值对的个数 30 $redis->hkeys($key); //获取hash中所有的键 31 $redis->hvals($key); //获取hash中所有的值 32 $redis->del($key); //删除key值 33 34 //redis list 列表 35 $index = $start = 0; 36 $redis->lpush($key, ‘val1‘, ‘val2‘); //在list的开头添加多个值 37 $redis->lpop($key); //移除并获取list的第一个元素 38 $redis->rpop($key); //移除并获取list的最后一个元素 39 $stop = $redis->llen($key) - 1; //获取list的长度 40 $redis->lindex($key, $index); //通过索引获取list元素 41 $redis->lrange($key, $start, $stop); //获取指定范围内的元素 42 43 $redis->del($key); 44 45 //redis set 无序集合 46 $redis->sadd($key, ‘val1‘, ‘val2‘); //向集合中添加多个元素 47 $redis->scard($key); //获取集合元素个数 48 $redis->spop($key); //移除并获取集合内随机一个元素 49 $redis->srem($key, ‘val1‘, ‘val2‘); //移除集合的多个元素 50 $redis->sismember($key, ‘val1‘); //判断元素是否存在于集合内 51 52 $redis->del($key); 53 //redis sorted set 有序集合 54 //有序集合里的元素都和一个分数score关联,就靠这个分数score对元素进行排序 55 $redis->zadd($key, $score1, $val1, $score2, $val2); //向集合内添加多个元素 56 $redis->zcard($key); //获取集合内元素总数 57 $redis->zcount($key, $minScore, $maxScore); //获取集合内分类范围内的元素 58 $redis->zrem($key, $member1, $member2); //移除集合内多个元素
其中Redis类的源码
1 <?php 2 /** 3 * Helper autocomplete for php redis extension 4 * @author Max Kamashev <max.kamashev@gmail.com> 5 * @link https://github.com/ukko/phpredis-phpdoc 6 * 7 * @method echo string $string Sends a string to Redis, which replies with the same string 8 * 9 * @method eval( $script, $args = array(), $numKeys = 0 ) 10 * Evaluate a LUA script serverside 11 * @param string $script 12 * @param array $args 13 * @param int $numKeys 14 * @return Mixed. What is returned depends on what the LUA script itself returns, which could be a scalar value 15 * (int/string), or an array. Arrays that are returned can also contain other arrays, if that‘s how it was set up in 16 * your LUA script. If there is an error executing the LUA script, the getLastError() function can tell you the 17 * message that came back from Redis (e.g. compile error). 18 * @link http://redis.io/commands/eval 19 * @example 20 * <pre> 21 * $redis->eval("return 1"); // Returns an integer: 1 22 * $redis->eval("return {1,2,3}"); // Returns Array(1,2,3) 23 * $redis->del(‘mylist‘); 24 * $redis->rpush(‘mylist‘,‘a‘); 25 * $redis->rpush(‘mylist‘,‘b‘); 26 * $redis->rpush(‘mylist‘,‘c‘); 27 * // Nested response: Array(1,2,3,Array(‘a‘,‘b‘,‘c‘)); 28 * $redis->eval("return {1,2,3,redis.call(‘lrange‘,‘mylist‘,0,-1)}}"); 29 * </pre> 30 * 31 */ 32 class Redis 33 { 34 const AFTER = ‘after‘; 35 const BEFORE = ‘before‘; 36 37 /** 38 * Options 39 */ 40 const OPT_SERIALIZER = 1; 41 const OPT_PREFIX = 2; 42 const OPT_READ_TIMEOUT = 3; 43 const OPT_SCAN = 4; 44 45 /** 46 * Serializers 47 */ 48 const SERIALIZER_NONE = 0; 49 const SERIALIZER_PHP = 1; 50 const SERIALIZER_IGBINARY = 2; 51 52 /** 53 * Multi 54 */ 55 const ATOMIC = 0; 56 const MULTI = 1; 57 const PIPELINE = 2; 58 59 /** 60 * Type 61 */ 62 const REDIS_NOT_FOUND = 0; 63 const REDIS_STRING = 1; 64 const REDIS_SET = 2; 65 const REDIS_LIST = 3; 66 const REDIS_ZSET = 4; 67 const REDIS_HASH = 5; 68 69 70 /** 71 * Scan 72 */ 73 const SCAN_NORETRY = 0; 74 const SCAN_RETRY = 1; 75 76 /** 77 * Creates a Redis client 78 * 79 * @example $redis = new Redis(); 80 */ 81 public function __construct( ) {} 82 83 /** 84 * Connects to a Redis instance. 85 * 86 * @param string $host can be a host, or the path to a unix domain socket 87 * @param int $port optional 88 * @param float $timeout value in seconds (optional, default is 0.0 meaning unlimited) 89 * @return bool TRUE on success, FALSE on error. 90 * <pre> 91 * $redis->connect(‘127.0.0.1‘, 6379); 92 * $redis->connect(‘127.0.0.1‘); // port 6379 by default 93 * $redis->connect(‘127.0.0.1‘, 6379, 2.5); // 2.5 sec timeout. 94 * $redis->connect(‘/tmp/redis.sock‘); // unix domain socket. 95 * </pre> 96 */ 97 public function connect( $host, $port = 6379, $timeout = 0.0 ) {} 98 99 /** 100 * Set the string value in argument as value of the key, with a time to live. 101 * 102 * @param string $key 103 * @param int $ttl in milliseconds 104 * @param string $value 105 * @return bool: TRUE if the command is successful. 106 * @link http://redis.io/commands/setex 107 * $redis->psetex(‘key‘, 100, ‘value‘); // sets key → value, with 0.1 sec TTL. 108 */ 109 public function psetex($key, $ttl, $value) {} 110 111 /** 112 * Scan a set for members. 113 * 114 * @see scan() 115 * @param string $key 116 * @param int $iterator 117 * @param string $pattern 118 * @param int $count 119 * @return array|bool 120 */ 121 public function sScan($key, $iterator, $pattern = ‘‘, $count = 0) {} 122 123 /** 124 * Scan the keyspace for keys. 125 * 126 * @param int $iterator 127 * @param string $pattern 128 * @param int $count How many keys to return in a go (only a sugestion to Redis) 129 * @return array|bool an array of keys or FALSE if there are no more keys 130 * @link http://redis.io/commands/scan 131 * <pre> 132 * $it = NULL; // Initialize our iterator to NULL 133 * $redis->setOption(Redis::OPT_SCAN, Redis::SCAN_RETRY); // retry when we get no keys back 134 * while($arr_keys = $redis->scan($it)) { 135 * foreach($arr_keys as $str_key) { 136 * echo "Here is a key: $str_key\n"; 137 * } 138 * echo "No more keys to scan!\n"; 139 * } 140 * </pre> 141 */ 142 public function scan($iterator, $pattern = ‘‘, $count = 0) {} 143 144 /** 145 * Scan a sorted set for members, with optional pattern and count. 146 * 147 * @see scan() 148 * @param string $key 149 * @param int $iterator 150 * @param string $pattern 151 * @param int $count 152 * @return array|bool 153 */ 154 public function zScan($key, $iterator, $pattern = ‘‘, $count = 0) {} 155 156 /** 157 * Scan a HASH value for members, with an optional pattern and count. 158 * 159 * @see scan() 160 * @param string $key 161 * @param int $iterator 162 * @param string $pattern 163 * @param int $count 164 * @return array 165 */ 166 public function hScan($key, $iterator, $pattern = ‘‘, $count = 0) {} 167 168 169 170 /** 171 * Issue the CLIENT command with various arguments. 172 * @param string $command list | getname | setname | kill 173 * @param string $arg 174 * @return mixed 175 * @link http://redis.io/commands/client-list 176 * @link http://redis.io/commands/client-getname 177 * @link http://redis.io/commands/client-setname 178 * @link http://redis.io/commands/client-kill 179 * <pre> 180 * $redis->client(‘list‘); 181 * $redis->client(‘getname‘); 182 * $redis->client(‘setname‘, ‘somename‘); 183 * $redis->client(‘kill‘, <ip:port>); 184 * </pre> 185 * 186 * 187 * CLIENT LIST will return an array of arrays with client information. 188 * CLIENT GETNAME will return the client name or false if none has been set 189 * CLIENT SETNAME will return true if it can be set and false if not 190 * CLIENT KILL will return true if the client can be killed, and false if not 191 */ 192 public function client($command, $arg = ‘‘) {} 193 194 /** 195 * Access the Redis slow log. 196 * 197 * @param string $command get | len | reset 198 * @return mixed 199 * @link http://redis.io/commands/slowlog 200 * <pre> 201 * // Get ten slowlog entries 202 * $redis->slowlog(‘get‘, 10); 203 * 204 * // Get the default number of slowlog entries 205 * $redis->slowlog(‘get‘); 206 * 207 * // Reset our slowlog 208 * $redis->slowlog(‘reset‘); 209 * 210 * // Retrieve slowlog length 211 * $redis->slowlog(‘len‘); 212 * </pre> 213 */ 214 public function slowlog($command) {} 215 216 /** 217 * @see connect() 218 * @param string $host 219 * @param int $port 220 * @param float $timeout 221 */ 222 public function open( $host, $port = 6379, $timeout = 0.0 ) {} 223 224 /** 225 * Connects to a Redis instance or reuse a connection already established with pconnect/popen. 226 * 227 * The connection will not be closed on close or end of request until the php process ends. 228 * So be patient on to many open FD‘s (specially on redis server side) when using persistent connections on 229 * many servers connecting to one redis server. 230 * 231 * Also more than one persistent connection can be made identified by either host + port + timeout 232 * or unix socket + timeout. 233 * 234 * This feature is not available in threaded versions. pconnect and popen then working like their non persistent 235 * equivalents. 236 * 237 * @param string $host can be a host, or the path to a unix domain socket 238 * @param int $port optional 239 * @param float $timeout value in seconds (optional, default is 0 meaning unlimited) 240 * @return bool TRUE on success, FALSE on ertcnror. 241 * <pre> 242 * $redis->connect(‘127.0.0.1‘, 6379); 243 * $redis->connect(‘127.0.0.1‘); // port 6379 by default 244 * $redis->connect(‘127.0.0.1‘, 6379, 2.5); // 2.5 sec timeout. 245 * $redis->connect(‘/tmp/redis.sock‘); // unix domain socket. 246 * </pre> 247 */ 248 public function pconnect( $host, $port = 6379, $timeout = 0.0 ) {} 249 250 /** 251 * @see pconnect() 252 * @param string $host 253 * @param int $port 254 * @param float $timeout 255 */ 256 public function popen( $host, $port = 6379, $timeout = 0.0 ) {} 257 258 /** 259 * Disconnects from the Redis instance, except when pconnect is used. 260 */ 261 public function close( ) {} 262 263 /** 264 * Set client option. 265 * 266 * @param string $name parameter name 267 * @param string $value parameter value 268 * @return bool: TRUE on success, FALSE on error. 269 * @example 270 * <pre> 271 * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE); // don‘t serialize data 272 * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); // use built-in serialize/unserialize 273 * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY); // use igBinary serialize/unserialize 274 * $redis->setOption(Redis::OPT_PREFIX, ‘myAppName:‘); // use custom prefix on all keys 275 * </pre> 276 */ 277 public function setOption( $name, $value ) {} 278 279 /** 280 * Get client option 281 * 282 * @param string $name parameter name 283 * @return int Parameter value. 284 * @example 285 * // return Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP, or Redis::SERIALIZER_IGBINARY. 286 * $redis->getOption(Redis::OPT_SERIALIZER); 287 */ 288 public function getOption( $name ) {} 289 290 /** 291 * Check the current connection status 292 * 293 * @return string STRING: +PONG on success. Throws a RedisException object on connectivity error, as described above. 294 * @link http://redis.io/commands/ping 295 */ 296 public function ping( ) {} 297 298 /** 299 * Get the value related to the specified key 300 * 301 * @param string $key 302 * @return string|bool: If key didn‘t exist, FALSE is returned. Otherwise, the value related to this key is returned. 303 * @link http://redis.io/commands/get 304 * @example $redis->get(‘key‘); 305 */ 306 public function get( $key ) {} 307 308 309 /** 310 * Set the string value in argument as value of the key. 311 * 312 * @param string $key 313 * @param string $value 314 * @param int $timeout [optional] Calling setex() is preferred if you want a timeout. 315 * @return bool: TRUE if the command is successful. 316 * @link http://redis.io/commands/set 317 * @example $redis->set(‘key‘, ‘value‘); 318 */ 319 public function set( $key, $value, $timeout = 0 ) {} 320 321 /** 322 * Set the string value in argument as value of the key, with a time to live. 323 * 324 * @param string $key 325 * @param int $ttl 326 * @param string $value 327 * @return bool: TRUE if the command is successful. 328 * @link http://redis.io/commands/setex 329 * @example $redis->setex(‘key‘, 3600, ‘value‘); // sets key → value, with 1h TTL. 330 */ 331 public function setex( $key, $ttl, $value ) {} 332 333 /** 334 * Set the string value in argument as value of the key if the key doesn‘t already exist in the database. 335 * 336 * @param string $key 337 * @param string $value 338 * @return bool: TRUE in case of success, FALSE in case of failure. 339 * @link http://redis.io/commands/setnx 340 * @example 341 * <pre> 342 * $redis->setnx(‘key‘, ‘value‘); // return TRUE 343 * $redis->setnx(‘key‘, ‘value‘); // return FALSE 344 * </pre> 345 */ 346 public function setnx( $key, $value ) {} 347 348 /** 349 * Remove specified keys. 350 * 351 * @param int|array $key1 An array of keys, or an undefined number of parameters, each a key: key1 key2 key3 ... keyN 352 * @param string $key2 ... 353 * @param string $key3 ... 354 * @return int Number of keys deleted. 355 * @link http://redis.io/commands/del 356 * @example 357 * <pre> 358 * $redis->set(‘key1‘, ‘val1‘); 359 * $redis->set(‘key2‘, ‘val2‘); 360 * $redis->set(‘key3‘, ‘val3‘); 361 * $redis->set(‘key4‘, ‘val4‘); 362 * $redis->delete(‘key1‘, ‘key2‘); // return 2 363 * $redis->delete(array(‘key3‘, ‘key4‘)); // return 2 364 * </pre> 365 */ 366 public function del( $key1, $key2 = null, $key3 = null ) {} 367 368 /** 369 * @see del() 370 * @param $key1 371 * @param null $key2 372 * @param null $key3 373 */ 374 public function delete( $key1, $key2 = null, $key3 = null ) {} 375 376 /** 377 * Enter and exit transactional mode. 378 * 379 * @internal param Redis::MULTI|Redis::PIPELINE 380 * Defaults to Redis::MULTI. 381 * A Redis::MULTI block of commands runs as a single transaction; 382 * a Redis::PIPELINE block is simply transmitted faster to the server, but without any guarantee of atomicity. 383 * discard cancels a transaction. 384 * @return Redis returns the Redis instance and enters multi-mode. 385 * Once in multi-mode, all subsequent method calls return the same object until exec() is called. 386 * @link http://redis.io/commands/multi 387 * @example 388 * <pre> 389 * $ret = $redis->multi() 390 * ->set(‘key1‘, ‘val1‘) 391 * ->get(‘key1‘) 392 * ->set(‘key2‘, ‘val2‘) 393 * ->get(‘key2‘) 394 * ->exec(); 395 * 396 * //$ret == array ( 397 * // 0 => TRUE, 398 * // 1 => ‘val1‘, 399 * // 2 => TRUE, 400 * // 3 => ‘val2‘); 401 * </pre> 402 */ 403 public function multi( ) {} 404 405 /** 406 * @see multi() 407 * @link http://redis.io/commands/exec 408 */ 409 public function exec( ) {} 410 411 /** 412 * @see multi() 413 * @link http://redis.io/commands/discard 414 */ 415 public function discard( ) {} 416 417 /** 418 * Watches a key for modifications by another client. If the key is modified between WATCH and EXEC, 419 * the MULTI/EXEC transaction will fail (return FALSE). unwatch cancels all the watching of all keys by this client. 420 * @param string | array $key: a list of keys 421 * @return void 422 * @link http://redis.io/commands/watch 423 * @example 424 * <pre> 425 * $redis->watch(‘x‘); 426 * // long code here during the execution of which other clients could well modify `x` 427 * $ret = $redis->multi() 428 * ->incr(‘x‘) 429 * ->exec(); 430 * // $ret = FALSE if x has been modified between the call to WATCH and the call to EXEC. 431 * </pre> 432 */ 433 public function watch( $key ) {} 434 435 /** 436 * @see watch() 437 * @link http://redis.io/commands/unwatch 438 */ 439 public function unwatch( ) {} 440 441 /** 442 * Subscribe to channels. Warning: this function will probably change in the future. 443 * 444 * @param array $channels an array of channels to subscribe to 445 * @param string | array $callback either a string or an array($instance, ‘method_name‘). 446 * The callback function receives 3 parameters: the redis instance, the channel name, and the message. 447 * @link http://redis.io/commands/subscribe 448 * @example 449 * <pre> 450 * function f($redis, $chan, $msg) { 451 * switch($chan) { 452 * case ‘chan-1‘: 453 * ... 454 * break; 455 * 456 * case ‘chan-2‘: 457 * ... 458 * break; 459 * 460 * case ‘chan-2‘: 461 * ... 462 * break; 463 * } 464 * } 465 * 466 * $redis->subscribe(array(‘chan-1‘, ‘chan-2‘, ‘chan-3‘), ‘f‘); // subscribe to 3 chans 467 * </pre> 468 */ 469 public function subscribe( $channels, $callback ) {} 470 471 /** 472 * Subscribe to channels by pattern 473 * 474 * @param array $patterns The number of elements removed from the set. 475 * @param string|array $callback Either a string or an array with an object and method. 476 * The callback will get four arguments ($redis, $pattern, $channel, $message) 477 * @link http://redis.io/commands/psubscribe 478 * @example 479 * <pre> 480 * function psubscribe($redis, $pattern, $chan, $msg) { 481 * echo "Pattern: $pattern\n"; 482 * echo "Channel: $chan\n"; 483 * echo "Payload: $msg\n"; 484 * } 485 * </pre> 486 */ 487 public function psubscribe( $patterns, $callback ) {} 488 489 /** 490 * Publish messages to channels. Warning: this function will probably change in the future. 491 * 492 * @param string $channel a channel to publish to 493 * @param string $message string 494 * @link http://redis.io/commands/publish 495 * @return int Number of clients that received the message 496 * @example $redis->publish(‘chan-1‘, ‘hello, world!‘); // send message. 497 */ 498 public function publish( $channel, $message ) {} 499 500 /** 501 * Verify if the specified key exists. 502 * 503 * @param string $key 504 * @return bool: If the key exists, return TRUE, otherwise return FALSE. 505 * @link http://redis.io/commands/exists 506 * @example 507 * <pre> 508 * $redis->set(‘key‘, ‘value‘); 509 * $redis->exists(‘key‘); // TRUE 510 * $redis->exists(‘NonExistingKey‘); // FALSE 511 * </pre> 512 */ 513 public function exists( $key ) {} 514 515 /** 516 * Increment the number stored at key by one. 517 * 518 * @param string $key 519 * @return int the new value 520 * @link http://redis.io/commands/incr 521 * @example 522 * <pre> 523 * $redis->incr(‘key1‘); // key1 didn‘t exists, set to 0 before the increment and now has the value 1 524 * $redis->incr(‘key1‘); // 2 525 * $redis->incr(‘key1‘); // 3 526 * $redis->incr(‘key1‘); // 4 527 * </pre> 528 */ 529 public function incr( $key ) {} 530 531 /** 532 * Increment the float value of a key by the given amount 533 * 534 * @param string $key 535 * @param float $increment 536 * @return float 537 * @link http://redis.io/commands/incrbyfloat 538 * @example 539 * <pre> 540 * $redis = new Redis(); 541 * $redis->connect(‘127.0.0.1‘); 542 * $redis->set(‘x‘, 3); 543 * var_dump( $redis->incrByFloat(‘x‘, 1.5) ); // float(4.5) 544 * 545 * // ! SIC 546 * var_dump( $redis->get(‘x‘) ); // string(3) "4.5" 547 * </pre> 548 */ 549 public function incrByFloat( $key, $increment ) {} 550 551 /** 552 * Increment the number stored at key by one. If the second argument is filled, it will be used as the integer 553 * value of the increment. 554 * 555 * @param string $key key 556 * @param int $value value that will be added to key (only for incrBy) 557 * @return int the new value 558 * @link http://redis.io/commands/incrby 559 * @example 560 * <pre> 561 * $redis->incr(‘key1‘); // key1 didn‘t exists, set to 0 before the increment and now has the value 1 562 * $redis->incr(‘key1‘); // 2 563 * $redis->incr(‘key1‘); // 3 564 * $redis->incr(‘key1‘); // 4 565 * $redis->incrBy(‘key1‘, 10); // 14 566 * </pre> 567 */ 568 public function incrBy( $key, $value ) {} 569 570 /** 571 * Decrement the number stored at key by one. 572 * 573 * @param string $key 574 * @return int the new value 575 * @link http://redis.io/commands/decr 576 * @example 577 * <pre> 578 * $redis->decr(‘key1‘); // key1 didn‘t exists, set to 0 before the increment and now has the value -1 579 * $redis->decr(‘key1‘); // -2 580 * $redis->decr(‘key1‘); // -3 581 * </pre> 582 */ 583 public function decr( $key ) {} 584 585 /** 586 * Decrement the number stored at key by one. If the second argument is filled, it will be used as the integer 587 * value of the decrement. 588 * 589 * @param string $key 590 * @param int $value that will be substracted to key (only for decrBy) 591 * @return int the new value 592 * @link http://redis.io/commands/decrby 593 * @example 594 * <pre> 595 * $redis->decr(‘key1‘); // key1 didn‘t exists, set to 0 before the increment and now has the value -1 596 * $redis->decr(‘key1‘); // -2 597 * $redis->decr(‘key1‘); // -3 598 * $redis->decrBy(‘key1‘, 10); // -13 599 * </pre> 600 */ 601 public function decrBy( $key, $value ) {} 602 603 /** 604 * Get the values of all the specified keys. If one or more keys dont exist, the array will contain FALSE at the 605 * position of the key. 606 * 607 * @param array $keys Array containing the list of the keys 608 * @return array Array containing the values related to keys in argument 609 * @example 610 * <pre> 611 * $redis->set(‘key1‘, ‘value1‘); 612 * $redis->set(‘key2‘, ‘value2‘); 613 * $redis->set(‘key3‘, ‘value3‘); 614 * $redis->getMultiple(array(‘key1‘, ‘key2‘, ‘key3‘)); // array(‘value1‘, ‘value2‘, ‘value3‘); 615 * $redis->getMultiple(array(‘key0‘, ‘key1‘, ‘key5‘)); // array(`FALSE`, ‘value2‘, `FALSE`); 616 * </pre> 617 */ 618 public function getMultiple( array $keys ) {} 619 620 /** 621 * Adds the string values to the head (left) of the list. Creates the list if the key didn‘t exist. 622 * If the key exists and is not a list, FALSE is returned. 623 * 624 * @param string $key 625 * @param string $value1 String, value to push in key 626 * @param string $value2 Optional 627 * @param string $valueN Optional 628 * @return int The new length of the list in case of success, FALSE in case of Failure. 629 * @link http://redis.io/commands/lpush 630 * @example 631 * <pre> 632 * $redis->lPush(‘l‘, ‘v1‘, ‘v2‘, ‘v3‘, ‘v4‘) // int(4) 633 * var_dump( $redis->lRange(‘l‘, 0, -1) ); 634 * //// Output: 635 * // array(4) { 636 * // [0]=> string(2) "v4" 637 * // [1]=> string(2) "v3" 638 * // [2]=> string(2) "v2" 639 * // [3]=> string(2) "v1" 640 * // } 641 * </pre> 642 */ 643 public function lPush( $key, $value1, $value2 = null, $valueN = null ) {} 644 645 /** 646 * Adds the string values to the tail (right) of the list. Creates the list if the key didn‘t exist. 647 * If the key exists and is not a list, FALSE is returned. 648 * 649 * @param string $key 650 * @param string $value1 String, value to push in key 651 * @param string $value2 Optional 652 * @param string $valueN Optional 653 * @return int The new length of the list in case of success, FALSE in case of Failure. 654 * @link http://redis.io/commands/rpush 655 * @example 656 * <pre> 657 * $redis->rPush(‘l‘, ‘v1‘, ‘v2‘, ‘v3‘, ‘v4‘); // int(4) 658 * var_dump( $redis->lRange(‘l‘, 0, -1) ); 659 * //// Output: 660 * // array(4) { 661 * // [0]=> string(2) "v1" 662 * // [1]=> string(2) "v2" 663 * // [2]=> string(2) "v3" 664 * // [3]=> string(2) "v4" 665 * // } 666 * </pre> 667 */ 668 public function rPush( $key, $value1, $value2 = null, $valueN = null ) {} 669 670 /** 671 * Adds the string value to the head (left) of the list if the list exists. 672 * 673 * @param string $key 674 * @param string $value String, value to push in key 675 * @return int The new length of the list in case of success, FALSE in case of Failure. 676 * @link http://redis.io/commands/lpushx 677 * @example 678 * <pre> 679 * $redis->delete(‘key1‘); 680 * $redis->lPushx(‘key1‘, ‘A‘); // returns 0 681 * $redis->lPush(‘key1‘, ‘A‘); // returns 1 682 * $redis->lPushx(‘key1‘, ‘B‘); // returns 2 683 * $redis->lPushx(‘key1‘, ‘C‘); // returns 3 684 * // key1 now points to the following list: [ ‘A‘, ‘B‘, ‘C‘ ] 685 * </pre> 686 */ 687 public function lPushx( $key, $value ) {} 688 689 /** 690 * Adds the string value to the tail (right) of the list if the ist exists. FALSE in case of Failure. 691 * 692 * @param string $key 693 * @param string $value String, value to push in key 694 * @return int The new length of the list in case of success, FALSE in case of Failure. 695 * @link http://redis.io/commands/rpushx 696 * @example 697 * <pre> 698 * $redis->delete(‘key1‘); 699 * $redis->rPushx(‘key1‘, ‘A‘); // returns 0 700 * $redis->rPush(‘key1‘, ‘A‘); // returns 1 701 * $redis->rPushx(‘key1‘, ‘B‘); // returns 2 702 * $redis->rPushx(‘key1‘, ‘C‘); // returns 3 703 * // key1 now points to the following list: [ ‘A‘, ‘B‘, ‘C‘ ] 704 * </pre> 705 */ 706 public function rPushx( $key, $value ) {} 707 708 /** 709 * Returns and removes the first element of the list. 710 * 711 * @param string $key 712 * @return string if command executed successfully BOOL FALSE in case of failure (empty list) 713 * @link http://redis.io/commands/lpop 714 * @example 715 * <pre> 716 * $redis->rPush(‘key1‘, ‘A‘); 717 * $redis->rPush(‘key1‘, ‘B‘); 718 * $redis->rPush(‘key1‘, ‘C‘); // key1 => [ ‘A‘, ‘B‘, ‘C‘ ] 719 * $redis->lPop(‘key1‘); // key1 => [ ‘B‘, ‘C‘ ] 720 * </pre> 721 */ 722 public function lPop( $key ) {} 723 724 /** 725 * Returns and removes the last element of the list. 726 * 727 * @param string $key 728 * @return string if command executed successfully BOOL FALSE in case of failure (empty list) 729 * @link http://redis.io/commands/rpop 730 * @example 731 * <pre> 732 * $redis->rPush(‘key1‘, ‘A‘); 733 * $redis->rPush(‘key1‘, ‘B‘); 734 * $redis->rPush(‘key1‘, ‘C‘); // key1 => [ ‘A‘, ‘B‘, ‘C‘ ] 735 * $redis->rPop(‘key1‘); // key1 => [ ‘A‘, ‘B‘ ] 736 * </pre> 737 */ 738 public function rPop( $key ) {} 739 740 /** 741 * Is a blocking lPop primitive. If at least one of the lists contains at least one element, 742 * the element will be popped from the head of the list and returned to the caller. 743 * Il all the list identified by the keys passed in arguments are empty, blPop will block 744 * during the specified timeout until an element is pushed to one of those lists. This element will be popped. 745 * 746 * @param array $keys Array containing the keys of the lists INTEGER Timeout 747 * Or STRING Key1 STRING Key2 STRING Key3 ... STRING Keyn INTEGER Timeout 748 * @return array array(‘listName‘, ‘element‘) 749 * @link http://redis.io/commands/blpop 750 * @example 751 * <pre> 752 * // Non blocking feature 753 * $redis->lPush(‘key1‘, ‘A‘); 754 * $redis->delete(‘key2‘); 755 * 756 * $redis->blPop(‘key1‘, ‘key2‘, 10); // array(‘key1‘, ‘A‘) 757 * // OR 758 * $redis->blPop(array(‘key1‘, ‘key2‘), 10); // array(‘key1‘, ‘A‘) 759 * 760 * $redis->brPop(‘key1‘, ‘key2‘, 10); // array(‘key1‘, ‘A‘) 761 * // OR 762 * $redis->brPop(array(‘key1‘, ‘key2‘), 10); // array(‘key1‘, ‘A‘) 763 * 764 * // Blocking feature 765 * 766 * // process 1 767 * $redis->delete(‘key1‘); 768 * $redis->blPop(‘key1‘, 10); 769 * // blocking for 10 seconds 770 * 771 * // process 2 772 * $redis->lPush(‘key1‘, ‘A‘); 773 * 774 * // process 1 775 * // array(‘key1‘, ‘A‘) is returned 776 * </pre> 777 */ 778 public function blPop( array $keys ) {} 779 780 /** 781 * Is a blocking rPop primitive. If at least one of the lists contains at least one element, 782 * the element will be popped from the head of the list and returned to the caller. 783 * Il all the list identified by the keys passed in arguments are empty, brPop will 784 * block during the specified timeout until an element is pushed to one of those lists. T 785 * his element will be popped. 786 * 787 * @param array $keys Array containing the keys of the lists INTEGER Timeout 788 * Or STRING Key1 STRING Key2 STRING Key3 ... STRING Keyn INTEGER Timeout 789 * @return array array(‘listName‘, ‘element‘) 790 * @link http://redis.io/commands/brpop 791 * @example 792 * <pre> 793 * // Non blocking feature 794 * $redis->lPush(‘key1‘, ‘A‘); 795 * $redis->delete(‘key2‘); 796 * 797 * $redis->blPop(‘key1‘, ‘key2‘, 10); // array(‘key1‘, ‘A‘) 798 * // OR 799 * $redis->blPop(array(‘key1‘, ‘key2‘), 10); // array(‘key1‘, ‘A‘) 800 * 801 * $redis->brPop(‘key1‘, ‘key2‘, 10); // array(‘key1‘, ‘A‘) 802 * // OR 803 * $redis->brPop(array(‘key1‘, ‘key2‘), 10); // array(‘key1‘, ‘A‘) 804 * 805 * // Blocking feature 806 * 807 * // process 1 808 * $redis->delete(‘key1‘); 809 * $redis->blPop(‘key1‘, 10); 810 * // blocking for 10 seconds 811 * 812 * // process 2 813 * $redis->lPush(‘key1‘, ‘A‘); 814 * 815 * // process 1 816 * // array(‘key1‘, ‘A‘) is returned 817 * </pre> 818 */ 819 public function brPop( array $keys ) {} 820 821 822 /** 823 * Returns the size of a list identified by Key. If the list didn‘t exist or is empty, 824 * the command returns 0. If the data type identified by Key is not a list, the command return FALSE. 825 * 826 * @param string $key 827 * @return int The size of the list identified by Key exists. 828 * bool FALSE if the data type identified by Key is not list 829 * @link http://redis.io/commands/llen 830 * @example 831 * <pre> 832 * $redis->rPush(‘key1‘, ‘A‘); 833 * $redis->rPush(‘key1‘, ‘B‘); 834 * $redis->rPush(‘key1‘, ‘C‘); // key1 => [ ‘A‘, ‘B‘, ‘C‘ ] 835 * $redis->lLen(‘key1‘); // 3 836 * $redis->rPop(‘key1‘); 837 * $redis->lLen(‘key1‘); // 2 838 * </pre> 839 */ 840 public function lLen( $key ) {} 841 842 /** 843 * @see lLen() 844 * @param string $key 845 * @param int $index 846 * @link http://redis.io/commands/llen 847 */ 848 public function lSize( $key ) {} 849 850 851 /** 852 * Return the specified element of the list stored at the specified key. 853 * 0 the first element, 1 the second ... -1 the last element, -2 the penultimate ... 854 * Return FALSE in case of a bad index or a key that doesn‘t point to a list. 855 * @param string $key 856 * @param int $index 857 * @return String the element at this index 858 * Bool FALSE if the key identifies a non-string data type, or no value corresponds to this index in the list Key. 859 * @link http://redis.io/commands/lindex 860 * @example 861 * <pre> 862 * $redis->rPush(‘key1‘, ‘A‘); 863 * $redis->rPush(‘key1‘, ‘B‘); 864 * $redis->rPush(‘key1‘, ‘C‘); // key1 => [ ‘A‘, ‘B‘, ‘C‘ ] 865 * $redis->lGet(‘key1‘, 0); // ‘A‘ 866 * $redis->lGet(‘key1‘, -1); // ‘C‘ 867 * $redis->lGet(‘key1‘, 10); // `FALSE` 868 * </pre> 869 */ 870 public function lIndex( $key, $index ) {} 871 872 /** 873 * @see lIndex() 874 * @param string $key 875 * @param int $index 876 * @link http://redis.io/commands/lindex 877 */ 878 public function lGet( $key, $index ) {} 879 880 881 /** 882 * Set the list at index with the new value. 883 * 884 * @param string $key 885 * @param int $index 886 * @param string $value 887 * @return BOOL TRUE if the new value is setted. FALSE if the index is out of range, or data type identified by key 888 * is not a list. 889 * @link http://redis.io/commands/lset 890 * @example 891 * <pre> 892 * $redis->rPush(‘key1‘, ‘A‘); 893 * $redis->rPush(‘key1‘, ‘B‘); 894 * $redis->rPush(‘key1‘, ‘C‘); // key1 => [ ‘A‘, ‘B‘, ‘C‘ ] 895 * $redis->lGet(‘key1‘, 0); // ‘A‘ 896 * $redis->lSet(‘key1‘, 0, ‘X‘); 897 * $redis->lGet(‘key1‘, 0); // ‘X‘ 898 * </pre> 899 */ 900 public function lSet( $key, $index, $value ) {} 901 902 903 /** 904 * Returns the specified elements of the list stored at the specified key in 905 * the range [start, end]. start and stop are interpretated as indices: 0 the first element, 906 * 1 the second ... -1 the last element, -2 the penultimate ... 907 * @param string $key 908 * @param int $start 909 * @param int $end 910 * @return array containing the values in specified range. 911 * @link http://redis.io/commands/lrange 912 * @example 913 * <pre> 914 * $redis->rPush(‘key1‘, ‘A‘); 915 * $redis->rPush(‘key1‘, ‘B‘); 916 * $redis->rPush(‘key1‘, ‘C‘); 917 * $redis->lRange(‘key1‘, 0, -1); // array(‘A‘, ‘B‘, ‘C‘) 918 * </pre> 919 */ 920 public function lRange( $key, $start, $end ) {} 921 922 /** 923 * @see lRange() 924 * @link http://redis.io/commands/lrange 925 * @param string $key 926 * @param int $start 927 * @param int $end 928 */ 929 public function lGetRange( $key, $start, $end ) {} 930 931 932 /** 933 * Trims an existing list so that it will contain only a specified range of elements. 934 * 935 * @param string $key 936 * @param int $start 937 * @param int $stop 938 * @return array Bool return FALSE if the key identify a non-list value. 939 * @link http://redis.io/commands/ltrim 940 * @example 941 * <pre> 942 * $redis->rPush(‘key1‘, ‘A‘); 943 * $redis->rPush(‘key1‘, ‘B‘); 944 * $redis->rPush(‘key1‘, ‘C‘); 945 * $redis->lRange(‘key1‘, 0, -1); // array(‘A‘, ‘B‘, ‘C‘) 946 * $redis->lTrim(‘key1‘, 0, 1); 947 * $redis->lRange(‘key1‘, 0, -1); // array(‘A‘, ‘B‘) 948 * </pre> 949 */ 950 public function lTrim( $key, $start, $stop ) {} 951 952 /** 953 * @see lTrim() 954 * @link http://redis.io/commands/ltrim 955 * @param string $key 956 * @param int $start 957 * @param int $stop 958 */ 959 public function listTrim( $key, $start, $stop ) {} 960 961 962 /** 963 * Removes the first count occurences of the value element from the list. 964 * If count is zero, all the matching elements are removed. If count is negative, 965 * elements are removed from tail to head. 966 * 967 * @param string $key 968 * @param string $value 969 * @param int $count 970 * @return int the number of elements to remove 971 * bool FALSE if the value identified by key is not a list. 972 * @link http://redis.io/commands/lrem 973 * @example 974 * <pre> 975 * $redis->lPush(‘key1‘, ‘A‘); 976 * $redis->lPush(‘key1‘, ‘B‘); 977 * $redis->lPush(‘key1‘, ‘C‘); 978 * $redis->lPush(‘key1‘, ‘A‘); 979 * $redis->lPush(‘key1‘, ‘A‘); 980 * 981 * $redis->lRange(‘key1‘, 0, -1); // array(‘A‘, ‘A‘, ‘C‘, ‘B‘, ‘A‘) 982 * $redis->lRem(‘key1‘, ‘A‘, 2); // 2 983 * $redis->lRange(‘key1‘, 0, -1); // array(‘C‘, ‘B‘, ‘A‘) 984 * </pre> 985 */ 986 public function lRem( $key, $value, $count ) {} 987 988 /** 989 * @see lRem 990 * @link http://redis.io/commands/lremove 991 * @param string $key 992 * @param string $value 993 * @param int $count 994 */ 995 public function lRemove( $key, $value, $count ) {} 996 997 998 /** 999 * Insert value in the list before or after the pivot value. the parameter options 1000 * specify the position of the insert (before or after). If the list didn‘t exists, 1001 * or the pivot didn‘t exists, the value is not inserted. 1002 * 1003 * @param string $key 1004 * @param int $position Redis::BEFORE | Redis::AFTER 1005 * @param string $pivot 1006 * @param string $value 1007 * @return int The number of the elements in the list, -1 if the pivot didn‘t exists. 1008 * @link http://redis.io/commands/linsert 1009 * @example 1010 * <pre> 1011 * $redis->delete(‘key1‘); 1012 * $redis->lInsert(‘key1‘, Redis::AFTER, ‘A‘, ‘X‘); // 0 1013 * 1014 * $redis->lPush(‘key1‘, ‘A‘); 1015 * $redis->lPush(‘key1‘, ‘B‘); 1016 * $redis->lPush(‘key1‘, ‘C‘); 1017 * 1018 * $redis->lInsert(‘key1‘, Redis::BEFORE, ‘C‘, ‘X‘); // 4 1019 * $redis->lRange(‘key1‘, 0, -1); // array(‘A‘, ‘B‘, ‘X‘, ‘C‘) 1020 * 1021 * $redis->lInsert(‘key1‘, Redis::AFTER, ‘C‘, ‘Y‘); // 5 1022 * $redis->lRange(‘key1‘, 0, -1); // array(‘A‘, ‘B‘, ‘X‘, ‘C‘, ‘Y‘) 1023 * 1024 * $redis->lInsert(‘key1‘, Redis::AFTER, ‘W‘, ‘value‘); // -1 1025 * </pre> 1026 */ 1027 public function lInsert( $key, $position, $pivot, $value ) {} 1028 1029 1030 /** 1031 * Adds a values to the set value stored at key. 1032 * If this value is already in the set, FALSE is returned. 1033 * 1034 * @param string $key Required key 1035 * @param string $value1 Required value 1036 * @param string $value2 Optional value 1037 * @param string $valueN Optional value 1038 * @return int The number of elements added to the set 1039 * @link http://redis.io/commands/sadd 1040 * @example 1041 * <pre> 1042 * $redis->sAdd(‘k‘, ‘v1‘); // int(1) 1043 * $redis->sAdd(‘k‘, ‘v1‘, ‘v2‘, ‘v3‘); // int(2) 1044 * </pre> 1045 */ 1046 public function sAdd( $key, $value1, $value2 = null, $valueN = null ) {} 1047 1048 1049 /** 1050 * Removes the specified members from the set value stored at key. 1051 * 1052 * @param string $key 1053 * @param string $member1 1054 * @param string $member2 1055 * @param string $memberN 1056 * @return int The number of elements removed from the set. 1057 * @link http://redis.io/commands/srem 1058 * @example 1059 * <pre> 1060 * var_dump( $redis->sAdd(‘k‘, ‘v1‘, ‘v2‘, ‘v3‘) ); // int(3) 1061 * var_dump( $redis->sRem(‘k‘, ‘v2‘, ‘v3‘) ); // int(2) 1062 * var_dump( $redis->sMembers(‘k‘) ); 1063 * //// Output: 1064 * // array(1) { 1065 * // [0]=> string(2) "v1" 1066 * // } 1067 * </pre> 1068 */ 1069 public function sRem( $key, $member1, $member2 = null, $memberN = null ) {} 1070 1071 /** 1072 * @see sRem() 1073 * @link http://redis.io/commands/srem 1074 * @param string $key 1075 * @param string $member1 1076 * @param string $member2 1077 * @param string $memberN 1078 */ 1079 public function sRemove( $key, $member1, $member2 = null, $memberN = null ) {} 1080 1081 1082 /** 1083 * Moves the specified member from the set at srcKey to the set at dstKey. 1084 * 1085 * @param string $srcKey 1086 * @param string $dstKey 1087 * @param string $member 1088 * @return bool If the operation is successful, return TRUE. 1089 * If the srcKey and/or dstKey didn‘t exist, and/or the member didn‘t exist in srcKey, FALSE is returned. 1090 * @link http://redis.io/commands/smove 1091 * @example 1092 * <pre> 1093 * $redis->sAdd(‘key1‘ , ‘set11‘); 1094 * $redis->sAdd(‘key1‘ , ‘set12‘); 1095 * $redis->sAdd(‘key1‘ , ‘set13‘); // ‘key1‘ => {‘set11‘, ‘set12‘, ‘set13‘} 1096 * $redis->sAdd(‘key2‘ , ‘set21‘); 1097 * $redis->sAdd(‘key2‘ , ‘set22‘); // ‘key2‘ => {‘set21‘, ‘set22‘} 1098 * $redis->sMove(‘key1‘, ‘key2‘, ‘set13‘); // ‘key1‘ => {‘set11‘, ‘set12‘} 1099 * // ‘key2‘ => {‘set21‘, ‘set22‘, ‘set13‘} 1100 * </pre> 1101 */ 1102 public function sMove( $srcKey, $dstKey, $member ) {} 1103 1104 1105 /** 1106 * Checks if value is a member of the set stored at the key key. 1107 * 1108 * @param string $key 1109 * @param string $value 1110 * @return bool TRUE if value is a member of the set at key key, FALSE otherwise. 1111 * @link http://redis.io/commands/sismember 1112 * @example 1113 * <pre> 1114 * $redis->sAdd(‘key1‘ , ‘set1‘); 1115 * $redis->sAdd(‘key1‘ , ‘set2‘); 1116 * $redis->sAdd(‘key1‘ , ‘set3‘); // ‘key1‘ => {‘set1‘, ‘set2‘, ‘set3‘} 1117 * 1118 * $redis->sIsMember(‘key1‘, ‘set1‘); // TRUE 1119 * $redis->sIsMember(‘key1‘, ‘setX‘); // FALSE 1120 * </pre> 1121 */ 1122 public function sIsMember( $key, $value ) {} 1123 1124 /** 1125 * @see sIsMember() 1126 * @link http://redis.io/commands/sismember 1127 * @param string $key 1128 * @param string $value 1129 */ 1130 public function sContains( $key, $value ) {} 1131 1132 /** 1133 * Returns the cardinality of the set identified by key. 1134 * 1135 * @param string $key 1136 * @return int the cardinality of the set identified by key, 0 if the set doesn‘t exist. 1137 * @link http://redis.io/commands/scard 1138 * @example 1139 * <pre> 1140 * $redis->sAdd(‘key1‘ , ‘set1‘); 1141 * $redis->sAdd(‘key1‘ , ‘set2‘); 1142 * $redis->sAdd(‘key1‘ , ‘set3‘); // ‘key1‘ => {‘set1‘, ‘set2‘, ‘set3‘} 1143 * $redis->sCard(‘key1‘); // 3 1144 * $redis->sCard(‘keyX‘); // 0 1145 * </pre> 1146 */ 1147 public function sCard( $key ) {} 1148 1149 1150 /** 1151 * Removes and returns a random element from the set value at Key. 1152 * 1153 * @param string $key 1154 * @return string "popped" value 1155 * bool FALSE if set identified by key is empty or doesn‘t exist. 1156 * @link http://redis.io/commands/spop 1157 * @example 1158 * <pre> 1159 * $redis->sAdd(‘key1‘ , ‘set1‘); 1160 * $redis->sAdd(‘key1‘ , ‘set2‘); 1161 * $redis->sAdd(‘key1‘ , ‘set3‘); // ‘key1‘ => {‘set3‘, ‘set1‘, ‘set2‘} 1162 * $redis->sPop(‘key1‘); // ‘set1‘, ‘key1‘ => {‘set3‘, ‘set2‘} 1163 * $redis->sPop(‘key1‘); // ‘set3‘, ‘key1‘ => {‘set2‘} 1164 * </pre> 1165 */ 1166 public function sPop( $key ) {} 1167 1168 1169 /** 1170 * Returns a random element from the set value at Key, without removing it. 1171 * 1172 * @param string $key 1173 * @return string value from the set 1174 * bool FALSE if set identified by key is empty or doesn‘t exist. 1175 * @link http://redis.io/commands/srandmember 1176 * @example 1177 * <pre> 1178 * $redis->sAdd(‘key1‘ , ‘set1‘); 1179 * $redis->sAdd(‘key1‘ , ‘set2‘); 1180 * $redis->sAdd(‘key1‘ , ‘set3‘); // ‘key1‘ => {‘set3‘, ‘set1‘, ‘set2‘} 1181 * $redis->sRandMember(‘key1‘); // ‘set1‘, ‘key1‘ => {‘set3‘, ‘set1‘, ‘set2‘} 1182 * $redis->sRandMember(‘key1‘); // ‘set3‘, ‘key1‘ => {‘set3‘, ‘set1‘, ‘set2‘} 1183 * </pre> 1184 */ 1185 public function sRandMember( $key ) {} 1186 1187 /** 1188 * Returns the members of a set resulting from the intersection of all the sets 1189 * held at the specified keys. If just a single key is specified, then this command 1190 * produces the members of this set. If one of the keys is missing, FALSE is returned. 1191 * 1192 * @param string $key1 keys identifying the different sets on which we will apply the intersection. 1193 * @param string $key2 ... 1194 * @param string $keyN ... 1195 * @return array, contain the result of the intersection between those keys. 1196 * If the intersection between the different sets is empty, the return value will be empty array. 1197 * @link http://redis.io/commands/sinterstore 1198 * @example 1199 * <pre> 1200 * $redis->sAdd(‘key1‘, ‘val1‘); 1201 * $redis->sAdd(‘key1‘, ‘val2‘); 1202 * $redis->sAdd(‘key1‘, ‘val3‘); 1203 * $redis->sAdd(‘key1‘, ‘val4‘); 1204 * 1205 * $redis->sAdd(‘key2‘, ‘val3‘); 1206 * $redis->sAdd(‘key2‘, ‘val4‘); 1207 * 1208 * $redis->sAdd(‘key3‘, ‘val3‘); 1209 * $redis->sAdd(‘key3‘, ‘val4‘); 1210 * 1211 * var_dump($redis->sInter(‘key1‘, ‘key2‘, ‘key3‘)); 1212 * 1213 * //array(2) { 1214 * // [0]=> 1215 * // string(4) "val4" 1216 * // [1]=> 1217 * // string(4) "val3" 1218 * //} 1219 * </pre> 1220 */ 1221 public function sInter( $key1, $key2, $keyN = null ) {} 1222 1223 /** 1224 * Performs a sInter command and stores the result in a new set. 1225 * 1226 * @param string $dstKey the key to store the diff into. 1227 * @param string $key1 are intersected as in sInter. 1228 * @param string $key2 ... 1229 * @param string $keyN ... 1230 * @return int: The cardinality of the resulting set, or FALSE in case of a missing key. 1231 * @link http://redis.io/commands/sinterstore 1232 * @example 1233 * <pre> 1234 * $redis->sAdd(‘key1‘, ‘val1‘); 1235 * $redis->sAdd(‘key1‘, ‘val2‘); 1236 * $redis->sAdd(‘key1‘, ‘val3‘); 1237 * $redis->sAdd(‘key1‘, ‘val4‘); 1238 * 1239 * $redis->sAdd(‘key2‘, ‘val3‘); 1240 * $redis->sAdd(‘key2‘, ‘val4‘); 1241 * 1242 * $redis->sAdd(‘key3‘, ‘val3‘); 1243 * $redis->sAdd(‘key3‘, ‘val4‘); 1244 * 1245 * var_dump($redis->sInterStore(‘output‘, ‘key1‘, ‘key2‘, ‘key3‘)); 1246 * var_dump($redis->sMembers(‘output‘)); 1247 * 1248 * //int(2) 1249 * // 1250 * //array(2) { 1251 * // [0]=> 1252 * // string(4) "val4" 1253 * // [1]=> 1254 * // string(4) "val3" 1255 * //} 1256 * </pre> 1257 */ 1258 public function sInterStore( $dstKey, $key1, $key2, $keyN = null ) {} 1259 1260 /** 1261 * Performs the union between N sets and returns it. 1262 * 1263 * @param string $key1 Any number of keys corresponding to sets in redis. 1264 * @param string $key2 ... 1265 * @param string $keyN ... 1266 * @return array of strings: The union of all these sets. 1267 * @link http://redis.io/commands/sunionstore 1268 * @example 1269 * <pre> 1270 * $redis->delete(‘s0‘, ‘s1‘, ‘s2‘); 1271 * 1272 * $redis->sAdd(‘s0‘, ‘1‘); 1273 * $redis->sAdd(‘s0‘, ‘2‘); 1274 * $redis->sAdd(‘s1‘, ‘3‘); 1275 * $redis->sAdd(‘s1‘, ‘1‘); 1276 * $redis->sAdd(‘s2‘, ‘3‘); 1277 * $redis->sAdd(‘s2‘, ‘4‘); 1278 * 1279 * var_dump($redis->sUnion(‘s0‘, ‘s1‘, ‘s2‘)); 1280 * 1281 * array(4) { 1282 * // [0]=> 1283 * // string(1) "3" 1284 * // [1]=> 1285 * // string(1) "4" 1286 * // [2]=> 1287 * // string(1) "1" 1288 * // [3]=> 1289 * // string(1) "2" 1290 * //} 1291 * </pre> 1292 */ 1293 public function sUnion( $key1, $key2, $keyN = null ) {} 1294 1295 /** 1296 * Performs the same action as sUnion, but stores the result in the first key 1297 * 1298 * @param string $dstKey the key to store the diff into. 1299 * @param string $key1 Any number of keys corresponding to sets in redis. 1300 * @param string $key2 ... 1301 * @param string $keyN ... 1302 * @return int Any number of keys corresponding to sets in redis. 1303 * @link http://redis.io/commands/sunionstore 1304 * @example 1305 * <pre> 1306 * $redis->delete(‘s0‘, ‘s1‘, ‘s2‘); 1307 * 1308 * $redis->sAdd(‘s0‘, ‘1‘); 1309 * $redis->sAdd(‘s0‘, ‘2‘); 1310 * $redis->sAdd(‘s1‘, ‘3‘); 1311 * $redis->sAdd(‘s1‘, ‘1‘); 1312 * $redis->sAdd(‘s2‘, ‘3‘); 1313 * $redis->sAdd(‘s2‘, ‘4‘); 1314 * 1315 * var_dump($redis->sUnionStore(‘dst‘, ‘s0‘, ‘s1‘, ‘s2‘)); 1316 * var_dump($redis->sMembers(‘dst‘)); 1317 * 1318 * //int(4) 1319 * //array(4) { 1320 * // [0]=> 1321 * // string(1) "3" 1322 * // [1]=> 1323 * // string(1) "4" 1324 * // [2]=> 1325 * // string(1) "1" 1326 * // [3]=> 1327 * // string(1) "2" 1328 * //} 1329 * </pre> 1330 */ 1331 public function sUnionStore( $dstKey, $key1, $key2, $keyN = null ) {} 1332 1333 /** 1334 * Performs the difference between N sets and returns it. 1335 * 1336 * @param string $key1 Any number of keys corresponding to sets in redis. 1337 * @param string $key2 ... 1338 * @param string $keyN ... 1339 * @return array of strings: The difference of the first set will all the others. 1340 * @link http://redis.io/commands/sdiff 1341 * @example 1342 * <pre> 1343 * $redis->delete(‘s0‘, ‘s1‘, ‘s2‘); 1344 * 1345 * $redis->sAdd(‘s0‘, ‘1‘); 1346 * $redis->sAdd(‘s0‘, ‘2‘); 1347 * $redis->sAdd(‘s0‘, ‘3‘); 1348 * $redis->sAdd(‘s0‘, ‘4‘); 1349 * 1350 * $redis->sAdd(‘s1‘, ‘1‘); 1351 * $redis->sAdd(‘s2‘, ‘3‘); 1352 * 1353 * var_dump($redis->sDiff(‘s0‘, ‘s1‘, ‘s2‘)); 1354 * 1355 * //array(2) { 1356 * // [0]=> 1357 * // string(1) "4" 1358 * // [1]=> 1359 * // string(1) "2" 1360 * //} 1361 * </pre> 1362 */ 1363 public function sDiff( $key1, $key2, $keyN = null ) {} 1364 1365 /** 1366 * Performs the same action as sDiff, but stores the result in the first key 1367 * 1368 * @param string $dstKey the key to store the diff into. 1369 * @param string $key1 Any number of keys corresponding to sets in redis 1370 * @param string $key2 ... 1371 * @param string $keyN ... 1372 * @return int: The cardinality of the resulting set, or FALSE in case of a missing key. 1373 * @link http://redis.io/commands/sdiffstore 1374 * @example 1375 * <pre> 1376 * $redis->delete(‘s0‘, ‘s1‘, ‘s2‘); 1377 * 1378 * $redis->sAdd(‘s0‘, ‘1‘); 1379 * $redis->sAdd(‘s0‘, ‘2‘); 1380 * $redis->sAdd(‘s0‘, ‘3‘); 1381 * $redis->sAdd(‘s0‘, ‘4‘); 1382 * 1383 * $redis->sAdd(‘s1‘, ‘1‘); 1384 * $redis->sAdd(‘s2‘, ‘3‘); 1385 * 1386 * var_dump($redis->sDiffStore(‘dst‘, ‘s0‘, ‘s1‘, ‘s2‘)); 1387 * var_dump($redis->sMembers(‘dst‘)); 1388 * 1389 * //int(2) 1390 * //array(2) { 1391 * // [0]=> 1392 * // string(1) "4" 1393 * // [1]=> 1394 * // string(1) "2" 1395 * //} 1396 * </pre> 1397 */ 1398 public function sDiffStore( $dstKey, $key1, $key2, $keyN = null ) {} 1399 1400 /** 1401 * Returns the contents of a set. 1402 * 1403 * @param string $key 1404 * @return array An array of elements, the contents of the set. 1405 * @link http://redis.io/commands/smembers 1406 * @example 1407 * <pre> 1408 * $redis->delete(‘s‘); 1409 * $redis->sAdd(‘s‘, ‘a‘); 1410 * $redis->sAdd(‘s‘, ‘b‘); 1411 * $redis->sAdd(‘s‘, ‘a‘); 1412 * $redis->sAdd(‘s‘, ‘c‘); 1413 * var_dump($redis->sMembers(‘s‘)); 1414 * 1415 * //array(3) { 1416 * // [0]=> 1417 * // string(1) "c" 1418 * // [1]=> 1419 * // string(1) "a" 1420 * // [2]=> 1421 * // string(1) "b" 1422 * //} 1423 * // The order is random and corresponds to redis‘ own internal representation of the set structure. 1424 * </pre> 1425 */ 1426 public function sMembers( $key ) {} 1427 1428 /** 1429 * @see sMembers() 1430 * @param string $key 1431 * @link http://redis.io/commands/smembers 1432 */ 1433 public function sGetMembers( $key ) {} 1434 1435 /** 1436 * Sets a value and returns the previous entry at that key. 1437 * 1438 * @param string $key 1439 * @param string $value 1440 * @return string A string, the previous value located at this key. 1441 * @link http://redis.io/commands/getset 1442 * @example 1443 * <pre> 1444 * $redis->set(‘x‘, ‘42‘); 1445 * $exValue = $redis->getSet(‘x‘, ‘lol‘); // return ‘42‘, replaces x by ‘lol‘ 1446 * $newValue = $redis->get(‘x‘)‘ // return ‘lol‘ 1447 * </pre> 1448 */ 1449 public function getSet( $key, $value ) {} 1450 1451 /** 1452 * Returns a random key. 1453 * 1454 * @return string: an existing key in redis. 1455 * @link http://redis.io/commands/randomkey 1456 * @example 1457 * <pre> 1458 * $key = $redis->randomKey(); 1459 * $surprise = $redis->get($key); // who knows what‘s in there. 1460 * </pre> 1461 */ 1462 public function randomKey( ) {} 1463 1464 1465 /** 1466 * Switches to a given database. 1467 * 1468 * @param int $dbindex 1469 * @return bool TRUE in case of success, FALSE in case of failure. 1470 * @link http://redis.io/commands/select 1471 * @example 1472 * <pre> 1473 * $redis->select(0); // switch to DB 0 1474 * $redis->set(‘x‘, ‘42‘); // write 42 to x 1475 * $redis->move(‘x‘, 1); // move to DB 1 1476 * $redis->select(1); // switch to DB 1 1477 * $redis->get(‘x‘); // will return 42 1478 * </pre> 1479 */ 1480 public function select( $dbindex ) {} 1481 1482 /** 1483 * Moves a key to a different database. 1484 * 1485 * @param string $key 1486 * @param int $dbindex 1487 * @return bool: TRUE in case of success, FALSE in case of failure. 1488 * @link http://redis.io/commands/move 1489 * @example 1490 * <pre> 1491 * $redis->select(0); // switch to DB 0 1492 * $redis->set(‘x‘, ‘42‘); // write 42 to x 1493 * $redis->move(‘x‘, 1); // move to DB 1 1494 * $redis->select(1); // switch to DB 1 1495 * $redis->get(‘x‘); // will return 42 1496 * </pre> 1497 */ 1498 public function move( $key, $dbindex ) {} 1499 1500 /** 1501 * Renames a key. 1502 * 1503 * @param string $srcKey 1504 * @param string $dstKey 1505 * @return bool: TRUE in case of success, FALSE in case of failure. 1506 * @link http://redis.io/commands/rename 1507 * @example 1508 * <pre> 1509 * $redis->set(‘x‘, ‘42‘); 1510 * $redis->rename(‘x‘, ‘y‘); 1511 * $redis->get(‘y‘); // → 42 1512 * $redis->get(‘x‘); // → `FALSE` 1513 * </pre> 1514 */ 1515 public function rename( $srcKey, $dstKey ) {} 1516 1517 /** 1518 * @see rename() 1519 * @link http://redis.io/commands/rename 1520 * @param string $srcKey 1521 * @param string $dstKey 1522 */ 1523 public function renameKey( $srcKey, $dstKey ) {} 1524 1525 /** 1526 * Renames a key. 1527 * 1528 * Same as rename, but will not replace a key if the destination already exists. 1529 * This is the same behaviour as setNx. 1530 * 1531 * @param string $srcKey 1532 * @param string $dstKey 1533 * @return bool: TRUE in case of success, FALSE in case of failure. 1534 * @link http://redis.io/commands/renamenx 1535 * @example 1536 * <pre> 1537 * $redis->set(‘x‘, ‘42‘); 1538 * $redis->rename(‘x‘, ‘y‘); 1539 * $redis->get(‘y‘); // → 42 1540 * $redis->get(‘x‘); // → `FALSE` 1541 * </pre> 1542 */ 1543 public function renameNx( $srcKey, $dstKey ) {} 1544 1545 /** 1546 * Sets an expiration date (a timeout) on an item. 1547 * 1548 * @param string $key The key that will disappear. 1549 * @param int $ttl The key‘s remaining Time To Live, in seconds. 1550 * @return bool: TRUE in case of success, FALSE in case of failure. 1551 * @link http://redis.io/commands/expire 1552 * @example 1553 * <pre> 1554 * $redis->set(‘x‘, ‘42‘); 1555 * $redis->setTimeout(‘x‘, 3); // x will disappear in 3 seconds. 1556 * sleep(5); // wait 5 seconds 1557 * $redis->get(‘x‘); // will return `FALSE`, as ‘x‘ has expired. 1558 * </pre> 1559 */ 1560 public function expire( $key, $ttl ) {} 1561 1562 /** 1563 * Sets an expiration date (a timeout in milliseconds) on an item. 1564 * 1565 * @param string $key The key that will disappear. 1566 * @param int $pttl The key‘s remaining Time To Live, in milliseconds. 1567 * @return bool: TRUE in case of success, FALSE in case of failure. 1568 * @link http://redis.io/commands/pexpire 1569 * @example 1570 * <pre> 1571 * $redis->set(‘x‘, ‘42‘); 1572 * $redis->pExpire(‘x‘, 11500); // x will disappear in 11500 milliseconds. 1573 * $redis->ttl(‘x‘); // 12 1574 * $redis->pttl(‘x‘); // 11500 1575 * </pre> 1576 */ 1577 public function pExpire( $key, $ttl ) {} 1578 1579 /** 1580 * @see expire() 1581 * @param string $key 1582 * @param int $ttl 1583 * @link http://redis.io/commands/expire 1584 */ 1585 public function setTimeout( $key, $ttl ) {} 1586 1587 /** 1588 * Sets an expiration date (a timestamp) on an item. 1589 * 1590 * @param string $key The key that will disappear. 1591 * @param int $timestamp Unix timestamp. The key‘s date of death, in seconds from Epoch time. 1592 * @return bool: TRUE in case of success, FALSE in case of failure. 1593 * @link http://redis.io/commands/expireat 1594 * @example 1595 * <pre> 1596 * $redis->set(‘x‘, ‘42‘); 1597 * $now = time(NULL); // current timestamp 1598 * $redis->expireAt(‘x‘, $now + 3); // x will disappear in 3 seconds. 1599 * sleep(5); // wait 5 seconds 1600 * $redis->get(‘x‘); // will return `FALSE`, as ‘x‘ has expired. 1601 * </pre> 1602 */ 1603 public function expireAt( $key, $timestamp ) {} 1604 1605 /** 1606 * Sets an expiration date (a timestamp) on an item. Requires a timestamp in milliseconds 1607 * 1608 * @param string $key The key that will disappear. 1609 * @param int $timestamp Unix timestamp. The key‘s date of death, in seconds from Epoch time. 1610 * @return bool: TRUE in case of success, FALSE in case of failure. 1611 * @link http://redis.io/commands/pexpireat 1612 * @example 1613 * <pre> 1614 * $redis->set(‘x‘, ‘42‘); 1615 * $redis->pExpireAt(‘x‘, 1555555555005); 1616 * echo $redis->ttl(‘x‘); // 218270121 1617 * echo $redis->pttl(‘x‘); // 218270120575 1618 * </pre> 1619 */ 1620 public function pExpireAt( $key, $timestamp ) {} 1621 1622 /** 1623 * Returns the keys that match a certain pattern. 1624 * 1625 * @param string $pattern pattern, using ‘*‘ as a wildcard. 1626 * @return array of STRING: The keys that match a certain pattern. 1627 * @link http://redis.io/commands/keys 1628 * @example 1629 * <pre> 1630 * $allKeys = $redis->keys(‘*‘); // all keys will match this. 1631 * $keyWithUserPrefix = $redis->keys(‘user*‘); 1632 * </pre> 1633 */ 1634 public function keys( $pattern ) {} 1635 1636 /** 1637 * @see keys() 1638 * @param string $pattern 1639 * @link http://redis.io/commands/keys 1640 */ 1641 public function getKeys( $pattern ) {} 1642 1643 /** 1644 * Returns the current database‘s size. 1645 * 1646 * @return int: DB size, in number of keys. 1647 * @link http://redis.io/commands/dbsize 1648 * @example 1649 * <pre> 1650 * $count = $redis->dbSize(); 1651 * echo "Redis has $count keys\n"; 1652 * </pre> 1653 */ 1654 public function dbSize( ) {} 1655 1656 /** 1657 * Authenticate the connection using a password. 1658 * Warning: The password is sent in plain-text over the network. 1659 * 1660 * @param string $password 1661 * @return bool: TRUE if the connection is authenticated, FALSE otherwise. 1662 * @link http://redis.io/commands/auth 1663 * @example $redis->auth(‘foobared‘); 1664 */ 1665 public function auth( $password ) {} 1666 1667 /** 1668 * Starts the background rewrite of AOF (Append-Only File) 1669 * 1670 * @return bool: TRUE in case of success, FALSE in case of failure. 1671 * @link http://redis.io/commands/bgrewriteaof 1672 * @example $redis->bgrewriteaof(); 1673 */ 1674 public function bgrewriteaof( ) {} 1675 1676 /** 1677 * Changes the slave status 1678 * Either host and port, or no parameter to stop being a slave. 1679 * 1680 * @param string $host [optional] 1681 * @param int $port [optional] 1682 * @return bool: TRUE in case of success, FALSE in case of failure. 1683 * @link http://redis.io/commands/slaveof 1684 * @example 1685 * <pre> 1686 * $redis->slaveof(‘10.0.1.7‘, 6379); 1687 * // ... 1688 * $redis->slaveof(); 1689 * </pre> 1690 */ 1691 public function slaveof( $host = ‘127.0.0.1‘, $port = 6379 ) {} 1692 1693 /** 1694 * Describes the object pointed to by a key. 1695 * The information to retrieve (string) and the key (string). 1696 * Info can be one of the following: 1697 * - "encoding" 1698 * - "refcount" 1699 * - "idletime" 1700 * 1701 * @param string $string 1702 * @param string $key 1703 * @return string for "encoding", int for "refcount" and "idletime", FALSE if the key doesn‘t exist. 1704 * @link http://redis.io/commands/object 1705 * @example 1706 * <pre> 1707 * $redis->object("encoding", "l"); // → ziplist 1708 * $redis->object("refcount", "l"); // → 1 1709 * $redis->object("idletime", "l"); // → 400 (in seconds, with a precision of 10 seconds). 1710 * </pre> 1711 */ 1712 public function object( $string = ‘‘, $key = ‘‘ ) {} 1713 1714 /** 1715 * Performs a synchronous save. 1716 * 1717 * @return bool: TRUE in case of success, FALSE in case of failure. 1718 * If a save is already running, this command will fail and return FALSE. 1719 * @link http://redis.io/commands/save 1720 * @example $redis->save(); 1721 */ 1722 public function save( ) {} 1723 1724 /** 1725 * Performs a background save. 1726 * 1727 * @return bool: TRUE in case of success, FALSE in case of failure. 1728 * If a save is already running, this command will fail and return FALSE. 1729 * @link http://redis.io/commands/bgsave 1730 * @example $redis->bgSave(); 1731 */ 1732 public function bgsave( ) {} 1733 1734 /** 1735 * Returns the timestamp of the last disk save. 1736 * 1737 * @return int: timestamp. 1738 * @link http://redis.io/commands/lastsave 1739 * @example $redis->lastSave(); 1740 */ 1741 public function lastSave( ) {} 1742 1743 1744 /** 1745 * Returns the type of data pointed by a given key. 1746 * 1747 * @param string $key 1748 * @return int 1749 * 1750 * Depending on the type of the data pointed by the key, 1751 * this method will return the following value: 1752 * - string: Redis::REDIS_STRING 1753 * - set: Redis::REDIS_SET 1754 * - list: Redis::REDIS_LIST 1755 * - zset: Redis::REDIS_ZSET 1756 * - hash: Redis::REDIS_HASH 1757 * - other: Redis::REDIS_NOT_FOUND 1758 * @link http://redis.io/commands/type 1759 * @example $redis->type(‘key‘); 1760 */ 1761 public function type( $key ) {} 1762 1763 /** 1764 * Append specified string to the string stored in specified key. 1765 * 1766 * @param string $key 1767 * @param string $value 1768 * @return int: Size of the value after the append 1769 * @link http://redis.io/commands/append 1770 * @example 1771 * <pre> 1772 * $redis->set(‘key‘, ‘value1‘); 1773 * $redis->append(‘key‘, ‘value2‘); // 12 1774 * $redis->get(‘key‘); // ‘value1value2‘ 1775 * </pre> 1776 */ 1777 public function append( $key, $value ) {} 1778 1779 1780 /** 1781 * Return a substring of a larger string 1782 * 1783 * @param string $key 1784 * @param int $start 1785 * @param int $end 1786 * @return string: the substring 1787 * @link http://redis.io/commands/getrange 1788 * @example 1789 * <pre> 1790 * $redis->set(‘key‘, ‘string value‘); 1791 * $redis->getRange(‘key‘, 0, 5); // ‘string‘ 1792 * $redis->getRange(‘key‘, -5, -1); // ‘value‘ 1793 * </pre> 1794 */ 1795 public function getRange( $key, $start, $end ) {} 1796 1797 /** 1798 * Return a substring of a larger string 1799 * 1800 * @deprecated 1801 * @param string $key 1802 * @param int $start 1803 * @param int $end 1804 */ 1805 public function substr( $key, $start, $end ) {} 1806 1807 1808 /** 1809 * Changes a substring of a larger string. 1810 * 1811 * @param string $key 1812 * @param int $offset 1813 * @param string $value 1814 * @return string: the length of the string after it was modified. 1815 * @link http://redis.io/commands/setrange 1816 * @example 1817 * <pre> 1818 * $redis->set(‘key‘, ‘Hello world‘); 1819 * $redis->setRange(‘key‘, 6, "redis"); // returns 11 1820 * $redis->get(‘key‘); // "Hello redis" 1821 * </pre> 1822 */ 1823 public function setRange( $key, $offset, $value ) {} 1824 1825 /** 1826 * Get the length of a string value. 1827 * 1828 * @param string $key 1829 * @return int 1830 * @link http://redis.io/commands/strlen 1831 * @example 1832 * <pre> 1833 * $redis->set(‘key‘, ‘value‘); 1834 * $redis->strlen(‘key‘); // 5 1835 * </pre> 1836 */ 1837 public function strlen( $key ) {} 1838 1839 /** 1840 * Return a single bit out of a larger string 1841 * 1842 * @param string $key 1843 * @param int $offset 1844 * @return int: the bit value (0 or 1) 1845 * @link http://redis.io/commands/getbit 1846 * @example 1847 * <pre> 1848 * $redis->set(‘key‘, "\x7f"); // this is 0111 1111 1849 * $redis->getBit(‘key‘, 0); // 0 1850 * $redis->getBit(‘key‘, 1); // 1 1851 * </pre> 1852 */ 1853 public function getBit( $key, $offset ) {} 1854 1855 /** 1856 * Changes a single bit of a string. 1857 * 1858 * @param string $key 1859 * @param int $offset 1860 * @param bool|int $value bool or int (1 or 0) 1861 * @return int: 0 or 1, the value of the bit before it was set. 1862 * @link http://redis.io/commands/setbit 1863 * @example 1864 * <pre> 1865 * $redis->set(‘key‘, "*"); // ord("*") = 42 = 0x2f = "0010 1010" 1866 * $redis->setBit(‘key‘, 5, 1); // returns 0 1867 * $redis->setBit(‘key‘, 7, 1); // returns 0 1868 * $redis->get(‘key‘); // chr(0x2f) = "/" = b("0010 1111") 1869 * </pre> 1870 */ 1871 public function setBit( $key, $offset, $value ) {} 1872 1873 /** 1874 * Count bits in a string. 1875 * 1876 * @param string $key 1877 * @return int The number of bits set to 1 in the value behind the input key. 1878 * @link http://redis.io/commands/bitcount 1879 * @example 1880 * <pre> 1881 * $redis->set(‘bit‘, ‘345‘); // // 11 0011 0011 0100 0011 0101 1882 * var_dump( $redis->bitCount(‘bit‘, 0, 0) ); // int(4) 1883 * var_dump( $redis->bitCount(‘bit‘, 1, 1) ); // int(3) 1884 * var_dump( $redis->bitCount(‘bit‘, 2, 2) ); // int(4) 1885 * var_dump( $redis->bitCount(‘bit‘, 0, 2) ); // int(11) 1886 * </pre> 1887 */ 1888 public function bitCount( $key ) {} 1889 1890 /** 1891 * Bitwise operation on multiple keys. 1892 * 1893 * @param string $operation either "AND", "OR", "NOT", "XOR" 1894 * @param string $retKey return key 1895 * @param string $key1 1896 * @param string $key2 1897 * @return int The size of the string stored in the destination key. 1898 * @link http://redis.io/commands/bitop 1899 * @example 1900 * <pre> 1901 * $redis->set(‘bit1‘, ‘1‘); // 11 0001 1902 * $redis->set(‘bit2‘, ‘2‘); // 11 0010 1903 * 1904 * $redis->bitOp(‘AND‘, ‘bit‘, ‘bit1‘, ‘bit2‘); // bit = 110000 1905 * $redis->bitOp(‘OR‘, ‘bit‘, ‘bit1‘, ‘bit2‘); // bit = 110011 1906 * $redis->bitOp(‘NOT‘, ‘bit‘, ‘bit1‘, ‘bit2‘); // bit = 110011 1907 * $redis->bitOp(‘XOR‘, ‘bit‘, ‘bit1‘, ‘bit2‘); // bit = 11 1908 * </pre> 1909 */ 1910 public function bitOp( $operation, $retKey, $key1, $key2, $key3 = null ) {} 1911 1912 /** 1913 * Removes all entries from the current database. 1914 * 1915 * @return bool: Always TRUE. 1916 * @link http://redis.io/commands/flushdb 1917 * @example $redis->flushDB(); 1918 */ 1919 public function flushDB( ) {} 1920 1921 /** 1922 * Removes all entries from all databases. 1923 * 1924 * @return bool: Always TRUE. 1925 * @link http://redis.io/commands/flushall 1926 * @example $redis->flushAll(); 1927 */ 1928 public function flushAll( ) {} 1929 1930 /** 1931 * Sort 1932 * 1933 * @param string $key 1934 * @param array $option array(key => value, ...) - optional, with the following keys and values: 1935 * - ‘by‘ => ‘some_pattern_*‘, 1936 * - ‘limit‘ => array(0, 1), 1937 * - ‘get‘ => ‘some_other_pattern_*‘ or an array of patterns, 1938 * - ‘sort‘ => ‘asc‘ or ‘desc‘, 1939 * - ‘alpha‘ => TRUE, 1940 * - ‘store‘ => ‘external-key‘ 1941 * @return array 1942 * An array of values, or a number corresponding to the number of elements stored if that was used. 1943 * @link http://redis.io/commands/sort 1944 * @example 1945 * <pre> 1946 * $redis->delete(‘s‘); 1947 * $redis->sadd(‘s‘, 5); 1948 * $redis->sadd(‘s‘, 4); 1949 * $redis->sadd(‘s‘, 2); 1950 * $redis->sadd(‘s‘, 1); 1951 * $redis->sadd(‘s‘, 3); 1952 * 1953 * var_dump($redis->sort(‘s‘)); // 1,2,3,4,5 1954 * var_dump($redis->sort(‘s‘, array(‘sort‘ => ‘desc‘))); // 5,4,3,2,1 1955 * var_dump($redis->sort(‘s‘, array(‘sort‘ => ‘desc‘, ‘store‘ => ‘out‘))); // (int)5 1956 * </pre> 1957 */ 1958 public function sort( $key, $option = null ) {} 1959 1960 1961 /** 1962 * Returns an associative array of strings and integers 1963 * @param string $option Optional. The option to provide redis. 1964 * SERVER | CLIENTS | MEMORY | PERSISTENCE | STATS | REPLICATION | CPU | CLASTER | KEYSPACE | COMANDSTATS 1965 * 1966 * Returns an associative array of strings and integers, with the following keys: 1967 * - redis_version 1968 * - redis_git_sha1 1969 * - redis_git_dirty 1970 * - arch_bits 1971 * - multiplexing_api 1972 * - process_id 1973 * - uptime_in_seconds 1974 * - uptime_in_days 1975 * - lru_clock 1976 * - used_cpu_sys 1977 * - used_cpu_user 1978 * - used_cpu_sys_children 1979 * - used_cpu_user_children 1980 * - connected_clients 1981 * - connected_slaves 1982 * - client_longest_output_list 1983 * - client_biggest_input_buf 1984 * - blocked_clients 1985 * - used_memory 1986 * - used_memory_human 1987 * - used_memory_peak 1988 * - used_memory_peak_human 1989 * - mem_fragmentation_ratio 1990 * - mem_allocator 1991 * - loading 1992 * - aof_enabled 1993 * - changes_since_last_save 1994 * - bgsave_in_progress 1995 * - last_save_time 1996 * - total_connections_received 1997 * - total_commands_processed 1998 * - expired_keys 1999 * - evicted_keys 2000 * - keyspace_hits 2001 * - keyspace_misses 2002 * - hash_max_zipmap_entries 2003 * - hash_max_zipmap_value 2004 * - pubsub_channels 2005 * - pubsub_patterns 2006 * - latest_fork_usec 2007 * - vm_enabled 2008 * - role 2009 * @link http://redis.io/commands/info 2010 * @return string 2011 * @example 2012 * <pre> 2013 * $redis->info(); 2014 * 2015 * or 2016 * 2017 * $redis->info("COMMANDSTATS"); //Information on the commands that have been run (>=2.6 only) 2018 * $redis->info("CPU"); // just CPU information from Redis INFO 2019 * </pre> 2020 */ 2021 public function info( $option = null ) {} 2022 2023 /** 2024 * Resets the statistics reported by Redis using the INFO command (`info()` function). 2025 * These are the counters that are reset: 2026 * - Keyspace hits 2027 * - Keyspace misses 2028 * - Number of commands processed 2029 * - Number of connections received 2030 * - Number of expired keys 2031 * 2032 * @return bool: `TRUE` in case of success, `FALSE` in case of failure. 2033 * @example $redis->resetStat(); 2034 * @link http://redis.io/commands/config-resetstat 2035 */ 2036 public function resetStat( ) {} 2037 2038 /** 2039 * Returns the time to live left for a given key, in seconds. If the key doesn‘t exist, FALSE is returned. 2040 * 2041 * @param string $key 2042 * @return int, the time left to live in seconds. 2043 * @link http://redis.io/commands/ttl 2044 * @example $redis->ttl(‘key‘); 2045 */ 2046 public function ttl( $key ) {} 2047 2048 /** 2049 * Returns a time to live left for a given key, in milliseconds. 2050 * 2051 * If the key doesn‘t exist, FALSE is returned. 2052 * 2053 * @param string $key 2054 * @return int the time left to live in milliseconds. 2055 * @link http://redis.io/commands/pttl 2056 * @example $redis->pttl(‘key‘); 2057 */ 2058 public function pttl( $key ) {} 2059 2060 /** 2061 * Remove the expiration timer from a key. 2062 * 2063 * @param string $key 2064 * @return bool: TRUE if a timeout was removed, FALSE if the key didn’t exist or didn’t have an expiration timer. 2065 * @link http://redis.io/commands/persist 2066 * @example $redis->persist(‘key‘); 2067 */ 2068 public function persist( $key ) {} 2069 2070 /** 2071 * Sets multiple key-value pairs in one atomic command. 2072 * MSETNX only returns TRUE if all the keys were set (see SETNX). 2073 * 2074 * @param array(key => value) $array Pairs: array(key => value, ...) 2075 * @return bool TRUE in case of success, FALSE in case of failure. 2076 * @link http://redis.io/commands/mset 2077 * @example 2078 * <pre> 2079 * $redis->mset(array(‘key0‘ => ‘value0‘, ‘key1‘ => ‘value1‘)); 2080 * var_dump($redis->get(‘key0‘)); 2081 * var_dump($redis->get(‘key1‘)); 2082 * // Output: 2083 * // string(6) "value0" 2084 * // string(6) "value1" 2085 * </pre> 2086 */ 2087 public function mset( array $array ) {} 2088 2089 2090 /** 2091 * Returns the values of all specified keys. 2092 * 2093 * For every key that does not hold a string value or does not exist, 2094 * the special value false is returned. Because of this, the operation never fails. 2095 * 2096 * @param array $array 2097 * @return array 2098 * @link http://redis.io/commands/mget 2099 * @example 2100 * <pre> 2101 * $redis->delete(‘x‘, ‘y‘, ‘z‘, ‘h‘); // remove x y z 2102 * $redis->mset(array(‘x‘ => ‘a‘, ‘y‘ => ‘b‘, ‘z‘ => ‘c‘)); 2103 * $redis->hset(‘h‘, ‘field‘, ‘value‘); 2104 * var_dump($redis->mget(array(‘x‘, ‘y‘, ‘z‘, ‘h‘))); 2105 * // Output: 2106 * // array(3) { 2107 * // [0]=> 2108 * // string(1) "a" 2109 * // [1]=> 2110 * // string(1) "b" 2111 * // [2]=> 2112 * // string(1) "c" 2113 * // [3]=> 2114 * // bool(false) 2115 * // } 2116 * </pre> 2117 */ 2118 public function mget( array $array ) {} 2119 2120 /** 2121 * @see mset() 2122 * @param array $array 2123 * @return int 1 (if the keys were set) or 0 (no key was set) 2124 * @link http://redis.io/commands/msetnx 2125 */ 2126 public function msetnx( array $array ) {} 2127 2128 /** 2129 * Pops a value from the tail of a list, and pushes it to the front of another list. 2130 * Also return this value. 2131 * 2132 * @since redis >= 1.1 2133 * @param string $srcKey 2134 * @param string $dstKey 2135 * @return string The element that was moved in case of success, FALSE in case of failure. 2136 * @link http://redis.io/commands/rpoplpush 2137 * @example 2138 * <pre> 2139 * $redis->delete(‘x‘, ‘y‘); 2140 * 2141 * $redis->lPush(‘x‘, ‘abc‘); 2142 * $redis->lPush(‘x‘, ‘def‘); 2143 * $redis->lPush(‘y‘, ‘123‘); 2144 * $redis->lPush(‘y‘, ‘456‘); 2145 * 2146 * // move the last of x to the front of y. 2147 * var_dump($redis->rpoplpush(‘x‘, ‘y‘)); 2148 * var_dump($redis->lRange(‘x‘, 0, -1)); 2149 * var_dump($redis->lRange(‘y‘, 0, -1)); 2150 * 2151 * //Output: 2152 * // 2153 * //string(3) "abc" 2154 * //array(1) { 2155 * // [0]=> 2156 * // string(3) "def" 2157 * //} 2158 * //array(3) { 2159 * // [0]=> 2160 * // string(3) "abc" 2161 * // [1]=> 2162 * // string(3) "456" 2163 * // [2]=> 2164 * // string(3) "123" 2165 * //} 2166 * </pre> 2167 */ 2168 public function rpoplpush( $srcKey, $dstKey ) {} 2169 2170 /** 2171 * A blocking version of rpoplpush, with an integral timeout in the third parameter. 2172 * 2173 * @param string $srcKey 2174 * @param string $dstKey 2175 * @param int $timeout 2176 * @return string The element that was moved in case of success, FALSE in case of timeout. 2177 * @link http://redis.io/commands/brpoplpush 2178 */ 2179 public function brpoplpush( $srcKey, $dstKey, $timeout ) {} 2180 2181 /** 2182 * Adds the specified member with a given score to the sorted set stored at key. 2183 * 2184 * @param string $key Required key 2185 * @param float $score1 Required score 2186 * @param string $value1 Required value 2187 * @param float $score2 Optional score 2188 * @param string $value2 Optional value 2189 * @param float $scoreN Optional score 2190 * @param string $valueN Optional value 2191 * @return int Number of values added 2192 * @link http://redis.io/commands/zadd 2193 * @example 2194 * <pre> 2195 * <pre> 2196 * $redis->zAdd(‘z‘, 1, ‘v2‘, 2, ‘v2‘, 3, ‘v3‘, 4, ‘v4‘ ); // int(2) 2197 * $redis->zRem(‘z‘, ‘v2‘, ‘v3‘); // int(2) 2198 * var_dump( $redis->zRange(‘z‘, 0, -1) ); 2199 * //// Output: 2200 * // array(2) { 2201 * // [0]=> string(2) "v1" 2202 * // [1]=> string(2) "v4" 2203 * // } 2204 * </pre> 2205 * </pre> 2206 */ 2207 public function zAdd( $key, $score1, $value1, $score2 = null, $value2 = null, $scoreN = null, $valueN = null ) {} 2208 2209 /** 2210 * Returns a range of elements from the ordered set stored at the specified key, 2211 * with values in the range [start, end]. start and stop are interpreted as zero-based indices: 2212 * 0 the first element, 2213 * 1 the second ... 2214 * -1 the last element, 2215 * -2 the penultimate ... 2216 * 2217 * @param string $key 2218 * @param int $start 2219 * @param int $end 2220 * @param bool $withscores 2221 * @return array Array containing the values in specified range. 2222 * @link http://redis.io/commands/zrange 2223 * @example 2224 * <pre> 2225 * $redis->zAdd(‘key1‘, 0, ‘val0‘); 2226 * $redis->zAdd(‘key1‘, 2, ‘val2‘); 2227 * $redis->zAdd(‘key1‘, 10, ‘val10‘); 2228 * $redis->zRange(‘key1‘, 0, -1); // array(‘val0‘, ‘val2‘, ‘val10‘) 2229 * // with scores 2230 * $redis->zRange(‘key1‘, 0, -1, true); // array(‘val0‘ => 0, ‘val2‘ => 2, ‘val10‘ => 10) 2231 * </pre> 2232 */ 2233 public function zRange( $key, $start, $end, $withscores = null ) {} 2234 2235 /** 2236 * Deletes a specified member from the ordered set. 2237 * 2238 * @param string $key 2239 * @param string $member1 2240 * @param string $member2 2241 * @param string $memberN 2242 * @return int Number of deleted values 2243 * @link http://redis.io/commands/zrem 2244 * @example 2245 * <pre> 2246 * $redis->zAdd(‘z‘, 1, ‘v2‘, 2, ‘v2‘, 3, ‘v3‘, 4, ‘v4‘ ); // int(2) 2247 * $redis->zRem(‘z‘, ‘v2‘, ‘v3‘); // int(2) 2248 * var_dump( $redis->zRange(‘z‘, 0, -1) ); 2249 * //// Output: 2250 * // array(2) { 2251 * // [0]=> string(2) "v1" 2252 * // [1]=> string(2) "v4" 2253 * // } 2254 * </pre> 2255 */ 2256 public function zRem( $key, $member1, $member2 = null, $memberN = null ) {} 2257 2258 /** 2259 * @see zRem() 2260 * @param string $key 2261 * @param string $member1 2262 * @param string $member2 2263 * @param string $memberN 2264 * @return int Number of deleted values 2265 * @link http://redis.io/commands/zrem 2266 */ 2267 public function zDelete( $key, $member1, $member2 = null, $memberN = null ) {} 2268 2269 /** 2270 * Returns the elements of the sorted set stored at the specified key in the range [start, end] 2271 * in reverse order. start and stop are interpretated as zero-based indices: 2272 * 0 the first element, 2273 * 1 the second ... 2274 * -1 the last element, 2275 * -2 the penultimate ... 2276 * 2277 * @param string $key 2278 * @param int $start 2279 * @param int $end 2280 * @param bool $withscore 2281 * @return array Array containing the values in specified range. 2282 * @link http://redis.io/commands/zrevrange 2283 * @example 2284 * <pre> 2285 * $redis->zAdd(‘key‘, 0, ‘val0‘); 2286 * $redis->zAdd(‘key‘, 2, ‘val2‘); 2287 * $redis->zAdd(‘key‘, 10, ‘val10‘); 2288 * $redis->zRevRange(‘key‘, 0, -1); // array(‘val10‘, ‘val2‘, ‘val0‘) 2289 * 2290 * // with scores 2291 * $redis->zRevRange(‘key‘, 0, -1, true); // array(‘val10‘ => 10, ‘val2‘ => 2, ‘val0‘ => 0) 2292 * </pre> 2293 */ 2294 public function zRevRange( $key, $start, $end, $withscore = null ) {} 2295 2296 /** 2297 * Returns the elements of the sorted set stored at the specified key which have scores in the 2298 * range [start,end]. Adding a parenthesis before start or end excludes it from the range. 2299 * +inf and -inf are also valid limits. 2300 * 2301 * zRevRangeByScore returns the same items in reverse order, when the start and end parameters are swapped. 2302 * 2303 * @param string $key 2304 * @param int $start 2305 * @param int $end 2306 * @param array $options Two options are available: 2307 * - withscores => TRUE, 2308 * - and limit => array($offset, $count) 2309 * @return array Array containing the values in specified range. 2310 * @link http://redis.io/commands/zrangebyscore 2311 * @example 2312 * <pre> 2313 * $redis->zAdd(‘key‘, 0, ‘val0‘); 2314 * $redis->zAdd(‘key‘, 2, ‘val2‘); 2315 * $redis->zAdd(‘key‘, 10, ‘val10‘); 2316 * $redis->zRangeByScore(‘key‘, 0, 3); // array(‘val0‘, ‘val2‘) 2317 * $redis->zRangeByScore(‘key‘, 0, 3, array(‘withscores‘ => TRUE); // array(‘val0‘ => 0, ‘val2‘ => 2) 2318 * $redis->zRangeByScore(‘key‘, 0, 3, array(‘limit‘ => array(1, 1)); // array(‘val2‘ => 2) 2319 * $redis->zRangeByScore(‘key‘, 0, 3, array(‘limit‘ => array(1, 1)); // array(‘val2‘) 2320 * $redis->zRangeByScore(‘key‘, 0, 3, array(‘withscores‘ => TRUE, ‘limit‘ => array(1, 1)); // array(‘val2‘ => 2) 2321 * </pre> 2322 */ 2323 public function zRangeByScore( $key, $start, $end, array $options = array() ) {} 2324 2325 /** 2326 * @see zRangeByScore() 2327 * @param string $key 2328 * @param int $start 2329 * @param int $end 2330 * @param array $options 2331 * 2332 * @return array 2333 */ 2334 public function zRevRangeByScore( $key, $start, $end, array $options = array() ) {} 2335 2336 /** 2337 * Returns the number of elements of the sorted set stored at the specified key which have 2338 * scores in the range [start,end]. Adding a parenthesis before start or end excludes it 2339 * from the range. +inf and -inf are also valid limits. 2340 * 2341 * @param string $key 2342 * @param string $start 2343 * @param string $end 2344 * @return int the size of a corresponding zRangeByScore. 2345 * @link http://redis.io/commands/zcount 2346 * @example 2347 * <pre> 2348 * $redis->zAdd(‘key‘, 0, ‘val0‘); 2349 * $redis->zAdd(‘key‘, 2, ‘val2‘); 2350 * $redis->zAdd(‘key‘, 10, ‘val10‘); 2351 * $redis->zCount(‘key‘, 0, 3); // 2, corresponding to array(‘val0‘, ‘val2‘) 2352 * </pre> 2353 */ 2354 public function zCount( $key, $start, $end ) {} 2355 2356 /** 2357 * Deletes the elements of the sorted set stored at the specified key which have scores in the range [start,end]. 2358 * 2359 * @param string $key 2360 * @param float|string $start double or "+inf" or "-inf" string 2361 * @param float|string $end double or "+inf" or "-inf" string 2362 * @return int The number of values deleted from the sorted set 2363 * @link http://redis.io/commands/zremrangebyscore 2364 * @example 2365 * <pre> 2366 * $redis->zAdd(‘key‘, 0, ‘val0‘); 2367 * $redis->zAdd(‘key‘, 2, ‘val2‘); 2368 * $redis->zAdd(‘key‘, 10, ‘val10‘); 2369 * $redis->zRemRangeByScore(‘key‘, 0, 3); // 2 2370 * </pre> 2371 */ 2372 public function zRemRangeByScore( $key, $start, $end ) {} 2373 2374 /** 2375 * @see zRemRangeByScore() 2376 * @param string $key 2377 * @param float $start 2378 * @param float $end 2379 */ 2380 public function zDeleteRangeByScore( $key, $start, $end ) {} 2381 2382 /** 2383 * Deletes the elements of the sorted set stored at the specified key which have rank in the range [start,end]. 2384 * 2385 * @param string $key 2386 * @param int $start 2387 * @param int $end 2388 * @return int The number of values deleted from the sorted set 2389 * @link http://redis.io/commands/zremrangebyrank 2390 * @example 2391 * <pre> 2392 * $redis->zAdd(‘key‘, 1, ‘one‘); 2393 * $redis->zAdd(‘key‘, 2, ‘two‘); 2394 * $redis->zAdd(‘key‘, 3, ‘three‘); 2395 * $redis->zRemRangeByRank(‘key‘, 0, 1); // 2 2396 * $redis->zRange(‘key‘, 0, -1, array(‘withscores‘ => TRUE)); // array(‘three‘ => 3) 2397 * </pre> 2398 */ 2399 public function zRemRangeByRank( $key, $start, $end ) {} 2400 2401 /** 2402 * @see zRemRangeByRank() 2403 * @param string $key 2404 * @param int $start 2405 * @param int $end 2406 * @link http://redis.io/commands/zremrangebyscore 2407 */ 2408 public function zDeleteRangeByRank( $key, $start, $end ) {} 2409 2410 /** 2411 * Returns the cardinality of an ordered set. 2412 * 2413 * @param string $key 2414 * @return int the set‘s cardinality 2415 * @link http://redis.io/commands/zsize 2416 * @example 2417 * <pre> 2418 * $redis->zAdd(‘key‘, 0, ‘val0‘); 2419 * $redis->zAdd(‘key‘, 2, ‘val2‘); 2420 * $redis->zAdd(‘key‘, 10, ‘val10‘); 2421 * $redis->zCard(‘key‘); // 3 2422 * </pre> 2423 */ 2424 public function zCard( $key ) {} 2425 2426 /** 2427 * @see zCard() 2428 * @param string $key 2429 */ 2430 public function zSize( $key ) {} 2431 2432 /** 2433 * Returns the score of a given member in the specified sorted set. 2434 * 2435 * @param string $key 2436 * @param string $member 2437 * @return float 2438 * @link http://redis.io/commands/zscore 2439 * @example 2440 * <pre> 2441 * $redis->zAdd(‘key‘, 2.5, ‘val2‘); 2442 * $redis->zScore(‘key‘, ‘val2‘); // 2.5 2443 * </pre> 2444 */ 2445 public function zScore( $key, $member ) {} 2446 2447 /** 2448 * Returns the rank of a given member in the specified sorted set, starting at 0 for the item 2449 * with the smallest score. zRevRank starts at 0 for the item with the largest score. 2450 * 2451 * @param string $key 2452 * @param string $member 2453 * @return int the item‘s score. 2454 * @link http://redis.io/commands/zrank 2455 * @example 2456 * <pre> 2457 * $redis->delete(‘z‘); 2458 * $redis->zAdd(‘key‘, 1, ‘one‘); 2459 * $redis->zAdd(‘key‘, 2, ‘two‘); 2460 * $redis->zRank(‘key‘, ‘one‘); // 0 2461 * $redis->zRank(‘key‘, ‘two‘); // 1 2462 * $redis->zRevRank(‘key‘, ‘one‘); // 1 2463 * $redis->zRevRank(‘key‘, ‘two‘); // 0 2464 * </pre> 2465 */ 2466 public function zRank( $key, $member ) {} 2467 2468 /** 2469 * @see zRank() 2470 * @param string $key 2471 * @param string $member 2472 * @return int the item‘s score 2473 * @link http://redis.io/commands/zrevrank 2474 */ 2475 public function zRevRank( $key, $member ) {} 2476 2477 /** 2478 * Increments the score of a member from a sorted set by a given amount. 2479 * 2480 * @param string $key 2481 * @param float $value (double) value that will be added to the member‘s score 2482 * @param string $member 2483 * @return float the new value 2484 * @link http://redis.io/commands/zincrby 2485 * @example 2486 * <pre> 2487 * $redis->delete(‘key‘); 2488 * $redis->zIncrBy(‘key‘, 2.5, ‘member1‘); // key or member1 didn‘t exist, so member1‘s score is to 0 2489 * // before the increment and now has the value 2.5 2490 * $redis->zIncrBy(‘key‘, 1, ‘member1‘); // 3.5 2491 * </pre> 2492 */ 2493 public function zIncrBy( $key, $value, $member ) {} 2494 2495 /** 2496 * Creates an union of sorted sets given in second argument. 2497 * The result of the union will be stored in the sorted set defined by the first argument. 2498 * The third optionnel argument defines weights to apply to the sorted sets in input. 2499 * In this case, the weights will be multiplied by the score of each element in the sorted set 2500 * before applying the aggregation. The forth argument defines the AGGREGATE option which 2501 * specify how the results of the union are aggregated. 2502 * 2503 * @param string $Output 2504 * @param array $ZSetKeys 2505 * @param array $Weights 2506 * @param string $aggregateFunction Either "SUM", "MIN", or "MAX": defines the behaviour to use on 2507 * duplicate entries during the zUnion. 2508 * @return int The number of values in the new sorted set. 2509 * @link http://redis.io/commands/zunionstore 2510 * @example 2511 * <pre> 2512 * $redis->delete(‘k1‘); 2513 * $redis->delete(‘k2‘); 2514 * $redis->delete(‘k3‘); 2515 * $redis->delete(‘ko1‘); 2516 * $redis->delete(‘ko2‘); 2517 * $redis->delete(‘ko3‘); 2518 * 2519 * $redis->zAdd(‘k1‘, 0, ‘val0‘); 2520 * $redis->zAdd(‘k1‘, 1, ‘val1‘); 2521 * 2522 * $redis->zAdd(‘k2‘, 2, ‘val2‘); 2523 * $redis->zAdd(‘k2‘, 3, ‘val3‘); 2524 * 2525 * $redis->zUnion(‘ko1‘, array(‘k1‘, ‘k2‘)); // 4, ‘ko1‘ => array(‘val0‘, ‘val1‘, ‘val2‘, ‘val3‘) 2526 * 2527 * // Weighted zUnion 2528 * $redis->zUnion(‘ko2‘, array(‘k1‘, ‘k2‘), array(1, 1)); // 4, ‘ko2‘ => array(‘val0‘, ‘val1‘, ‘val2‘, ‘val3‘) 2529 * $redis->zUnion(‘ko3‘, array(‘k1‘, ‘k2‘), array(5, 1)); // 4, ‘ko3‘ => array(‘val0‘, ‘val2‘, ‘val3‘, ‘val1‘) 2530 * </pre> 2531 */ 2532 public function zUnion($Output, $ZSetKeys, array $Weights = null, $aggregateFunction = ‘SUM‘) {} 2533 2534 /** 2535 * Creates an intersection of sorted sets given in second argument. 2536 * The result of the union will be stored in the sorted set defined by the first argument. 2537 * The third optional argument defines weights to apply to the sorted sets in input. 2538 * In this case, the weights will be multiplied by the score of each element in the sorted set 2539 * before applying the aggregation. The forth argument defines the AGGREGATE option which 2540 * specify how the results of the union are aggregated. 2541 * 2542 * @param string $Output 2543 * @param array $ZSetKeys 2544 * @param array $Weights 2545 * @param string $aggregateFunction Either "SUM", "MIN", or "MAX": 2546 * defines the behaviour to use on duplicate entries during the zInter. 2547 * @return int The number of values in the new sorted set. 2548 * @link http://redis.io/commands/zinterstore 2549 * @example 2550 * <pre> 2551 * $redis->delete(‘k1‘); 2552 * $redis->delete(‘k2‘); 2553 * $redis->delete(‘k3‘); 2554 * 2555 * $redis->delete(‘ko1‘); 2556 * $redis->delete(‘ko2‘); 2557 * $redis->delete(‘ko3‘); 2558 * $redis->delete(‘ko4‘); 2559 * 2560 * $redis->zAdd(‘k1‘, 0, ‘val0‘); 2561 * $redis->zAdd(‘k1‘, 1, ‘val1‘); 2562 * $redis->zAdd(‘k1‘, 3, ‘val3‘); 2563 * 2564 * $redis->zAdd(‘k2‘, 2, ‘val1‘); 2565 * $redis->zAdd(‘k2‘, 3, ‘val3‘); 2566 * 2567 * $redis->zInter(‘ko1‘, array(‘k1‘, ‘k2‘)); // 2, ‘ko1‘ => array(‘val1‘, ‘val3‘) 2568 * $redis->zInter(‘ko2‘, array(‘k1‘, ‘k2‘), array(1, 1)); // 2, ‘ko2‘ => array(‘val1‘, ‘val3‘) 2569 * 2570 * // Weighted zInter 2571 * $redis->zInter(‘ko3‘, array(‘k1‘, ‘k2‘), array(1, 5), ‘min‘); // 2, ‘ko3‘ => array(‘val1‘, ‘val3‘) 2572 * $redis->zInter(‘ko4‘, array(‘k1‘, ‘k2‘), array(1, 5), ‘max‘); // 2, ‘ko4‘ => array(‘val3‘, ‘val1‘) 2573 * </pre> 2574 */ 2575 public function zInter($Output, $ZSetKeys, array $Weights = null, $aggregateFunction = ‘SUM‘) {} 2576 2577 /** 2578 * Adds a value to the hash stored at key. If this value is already in the hash, FALSE is returned. 2579 * 2580 * @param string $key 2581 * @param string $hashKey 2582 * @param string $value 2583 * @return int 2584 * 1 if value didn‘t exist and was added successfully, 2585 * 0 if the value was already present and was replaced, FALSE if there was an error. 2586 * @link http://redis.io/commands/hset 2587 * @example 2588 * <pre> 2589 * $redis->delete(‘h‘) 2590 * $redis->hSet(‘h‘, ‘key1‘, ‘hello‘); // 1, ‘key1‘ => ‘hello‘ in the hash at "h" 2591 * $redis->hGet(‘h‘, ‘key1‘); // returns "hello" 2592 * 2593 * $redis->hSet(‘h‘, ‘key1‘, ‘plop‘); // 0, value was replaced. 2594 * $redis->hGet(‘h‘, ‘key1‘); // returns "plop" 2595 * </pre> 2596 */ 2597 public function hSet( $key, $hashKey, $value ) {} 2598 2599 /** 2600 * Adds a value to the hash stored at key only if this field isn‘t already in the hash. 2601 * 2602 * @param string $key 2603 * @param string $hashKey 2604 * @param string $value 2605 * @return bool TRUE if the field was set, FALSE if it was already present. 2606 * @link http://redis.io/commands/hsetnx 2607 * @example 2608 * <pre> 2609 * $redis->delete(‘h‘) 2610 * $redis->hSetNx(‘h‘, ‘key1‘, ‘hello‘); // TRUE, ‘key1‘ => ‘hello‘ in the hash at "h" 2611 * $redis->hSetNx(‘h‘, ‘key1‘, ‘world‘); // FALSE, ‘key1‘ => ‘hello‘ in the hash at "h". No change since the field 2612 * wasn‘t replaced. 2613 * </pre> 2614 */ 2615 public function hSetNx( $key, $hashKey, $value ) {} 2616 2617 /** 2618 * Gets a value from the hash stored at key. 2619 * If the hash table doesn‘t exist, or the key doesn‘t exist, FALSE is returned. 2620 * 2621 * @param string $key 2622 * @param string $hashKey 2623 * @return string The value, if the command executed successfully BOOL FALSE in case of failure 2624 * @link http://redis.io/commands/hget 2625 */ 2626 public function hGet($key, $hashKey) {} 2627 2628 /** 2629 * Returns the length of a hash, in number of items 2630 * 2631 * @param string $key 2632 * @return int the number of items in a hash, FALSE if the key doesn‘t exist or isn‘t a hash. 2633 * @link http://redis.io/commands/hlen 2634 * @example 2635 * <pre> 2636 * $redis->delete(‘h‘) 2637 * $redis->hSet(‘h‘, ‘key1‘, ‘hello‘); 2638 * $redis->hSet(‘h‘, ‘key2‘, ‘plop‘); 2639 * $redis->hLen(‘h‘); // returns 2 2640 * </pre> 2641 */ 2642 public function hLen( $key ) {} 2643 2644 /** 2645 * Removes a values from the hash stored at key. 2646 * If the hash table doesn‘t exist, or the key doesn‘t exist, FALSE is returned. 2647 * 2648 * @param string $key 2649 * @param string $hashKey1 2650 * @param string $hashKey2 2651 * @param string $hashKeyN 2652 * @return int Number of deleted fields 2653 * @link http://redis.io/commands/hdel 2654 * @example 2655 * <pre> 2656 * $redis->hMSet(‘h‘, 2657 * array( 2658 * ‘f1‘ => ‘v1‘, 2659 * ‘f2‘ => ‘v2‘, 2660 * ‘f3‘ => ‘v3‘, 2661 * ‘f4‘ => ‘v4‘, 2662 * )); 2663 * 2664 * var_dump( $redis->hDel(‘h‘, ‘f1‘) ); // int(1) 2665 * var_dump( $redis->hDel(‘h‘, ‘f2‘, ‘f3‘) ); // int(2) 2666 * s 2667 * var_dump( $redis->hGetAll(‘h‘) ); 2668 * //// Output: 2669 * // array(1) { 2670 * // ["f4"]=> string(2) "v4" 2671 * // } 2672 * </pre> 2673 */ 2674 public function hDel( $key, $hashKey1, $hashKey2 = null, $hashKeyN = null ) {} 2675 2676 /** 2677 * Returns the keys in a hash, as an array of strings. 2678 * 2679 * @param string $key 2680 * @return array An array of elements, the keys of the hash. This works like PHP‘s array_keys(). 2681 * @link http://redis.io/commands/hkeys 2682 * @example 2683 * <pre> 2684 * $redis->delete(‘h‘); 2685 * $redis->hSet(‘h‘, ‘a‘, ‘x‘); 2686 * $redis->hSet(‘h‘, ‘b‘, ‘y‘); 2687 * $redis->hSet(‘h‘, ‘c‘, ‘z‘); 2688 * $redis->hSet(‘h‘, ‘d‘, ‘t‘); 2689 * var_dump($redis->hKeys(‘h‘)); 2690 * 2691 * // Output: 2692 * // array(4) { 2693 * // [0]=> 2694 * // string(1) "a" 2695 * // [1]=> 2696 * // string(1) "b" 2697 * // [2]=> 2698 * // string(1) "c" 2699 * // [3]=> 2700 * // string(1) "d" 2701 * // } 2702 * // The order is random and corresponds to redis‘ own internal representation of the set structure. 2703 * </pre> 2704 */ 2705 public function hKeys( $key ) {} 2706 2707 /** 2708 * Returns the values in a hash, as an array of strings. 2709 * 2710 * @param string $key 2711 * @return array An array of elements, the values of the hash. This works like PHP‘s array_values(). 2712 * @link http://redis.io/commands/hvals 2713 * @example 2714 * <pre> 2715 * $redis->delete(‘h‘); 2716 * $redis->hSet(‘h‘, ‘a‘, ‘x‘); 2717 * $redis->hSet(‘h‘, ‘b‘, ‘y‘); 2718 * $redis->hSet(‘h‘, ‘c‘, ‘z‘); 2719 * $redis->hSet(‘h‘, ‘d‘, ‘t‘); 2720 * var_dump($redis->hVals(‘h‘)); 2721 * 2722 * // Output 2723 * // array(4) { 2724 * // [0]=> 2725 * // string(1) "x" 2726 * // [1]=> 2727 * // string(1) "y" 2728 * // [2]=> 2729 * // string(1) "z" 2730 * // [3]=> 2731 * // string(1) "t" 2732 * // } 2733 * // The order is random and corresponds to redis‘ own internal representation of the set structure. 2734 * </pre> 2735 */ 2736 public function hVals( $key ) {} 2737 2738 /** 2739 * Returns the whole hash, as an array of strings indexed by strings. 2740 * 2741 * @param string $key 2742 * @return array An array of elements, the contents of the hash. 2743 * @link http://redis.io/commands/hgetall 2744 * @example 2745 * <pre> 2746 * $redis->delete(‘h‘); 2747 * $redis->hSet(‘h‘, ‘a‘, ‘x‘); 2748 * $redis->hSet(‘h‘, ‘b‘, ‘y‘); 2749 * $redis->hSet(‘h‘, ‘c‘, ‘z‘); 2750 * $redis->hSet(‘h‘, ‘d‘, ‘t‘); 2751 * var_dump($redis->hGetAll(‘h‘)); 2752 * 2753 * // Output: 2754 * // array(4) { 2755 * // ["a"]=> 2756 * // string(1) "x" 2757 * // ["b"]=> 2758 * // string(1) "y" 2759 * // ["c"]=> 2760 * // string(1) "z" 2761 * // ["d"]=> 2762 * // string(1) "t" 2763 * // } 2764 * // The order is random and corresponds to redis‘ own internal representation of the set structure. 2765 * </pre> 2766 */ 2767 public function hGetAll( $key ) {} 2768 2769 /** 2770 * Verify if the specified member exists in a key. 2771 * 2772 * @param string $key 2773 * @param string $hashKey 2774 * @return bool: If the member exists in the hash table, return TRUE, otherwise return FALSE. 2775 * @link http://redis.io/commands/hexists 2776 * @example 2777 * <pre> 2778 * $redis->hSet(‘h‘, ‘a‘, ‘x‘); 2779 * $redis->hExists(‘h‘, ‘a‘); // TRUE 2780 * $redis->hExists(‘h‘, ‘NonExistingKey‘); // FALSE 2781 * </pre> 2782 */ 2783 public function hExists( $key, $hashKey ) {} 2784 2785 /** 2786 * Increments the value of a member from a hash by a given amount. 2787 * 2788 * @param string $key 2789 * @param string $hashKey 2790 * @param int $value (integer) value that will be added to the member‘s value 2791 * @return int the new value 2792 * @link http://redis.io/commands/hincrby 2793 * @example 2794 * <pre> 2795 * $redis->delete(‘h‘); 2796 * $redis->hIncrBy(‘h‘, ‘x‘, 2); // returns 2: h[x] = 2 now. 2797 * $redis->hIncrBy(‘h‘, ‘x‘, 1); // h[x] ← 2 + 1. Returns 3 2798 * </pre> 2799 */ 2800 public function hIncrBy( $key, $hashKey, $value ) {} 2801 2802 /** 2803 * Increment the float value of a hash field by the given amount 2804 * @param string $key 2805 * @param string $field 2806 * @param float $increment 2807 * @return float 2808 * @link http://redis.io/commands/hincrbyfloat 2809 * @example 2810 * <pre> 2811 * $redis = new Redis(); 2812 * $redis->connect(‘127.0.0.1‘); 2813 * $redis->hset(‘h‘, ‘float‘, 3); 2814 * $redis->hset(‘h‘, ‘int‘, 3); 2815 * var_dump( $redis->hIncrByFloat(‘h‘, ‘float‘, 1.5) ); // float(4.5) 2816 * 2817 * var_dump( $redis->hGetAll(‘h‘) ); 2818 * 2819 * // Output 2820 * array(2) { 2821 * ["float"]=> 2822 * string(3) "4.5" 2823 * ["int"]=> 2824 * string(1) "3" 2825 * } 2826 * </pre> 2827 */ 2828 public function hIncrByFloat( $key, $field, $increment ) {} 2829 2830 /** 2831 * Fills in a whole hash. Non-string values are converted to string, using the standard (string) cast. 2832 * NULL values are stored as empty strings 2833 * 2834 * @param string $key 2835 * @param array $hashKeys key → value array 2836 * @return bool 2837 * @link http://redis.io/commands/hmset 2838 * @example 2839 * <pre> 2840 * $redis->delete(‘user:1‘); 2841 * $redis->hMset(‘user:1‘, array(‘name‘ => ‘Joe‘, ‘salary‘ => 2000)); 2842 * $redis->hIncrBy(‘user:1‘, ‘salary‘, 100); // Joe earns 100 more now. 2843 * </pre> 2844 */ 2845 public function hMset( $key, $hashKeys ) {} 2846 2847 /** 2848 * Retirieve the values associated to the specified fields in the hash. 2849 * 2850 * @param string $key 2851 * @param array $hashKeys 2852 * @return array Array An array of elements, the values of the specified fields in the hash, 2853 * with the hash keys as array keys. 2854 * @link http://redis.io/commands/hmget 2855 * @example 2856 * <pre> 2857 * $redis->delete(‘h‘); 2858 * $redis->hSet(‘h‘, ‘field1‘, ‘value1‘); 2859 * $redis->hSet(‘h‘, ‘field2‘, ‘value2‘); 2860 * $redis->hmGet(‘h‘, array(‘field1‘, ‘field2‘)); // returns array(‘field1‘ => ‘value1‘, ‘field2‘ => ‘value2‘) 2861 * </pre> 2862 */ 2863 public function hMGet( $key, $hashKeys ) {} 2864 2865 /** 2866 * Get or Set the redis config keys. 2867 * 2868 * @param string $operation either `GET` or `SET` 2869 * @param string $key for `SET`, glob-pattern for `GET`. See http://redis.io/commands/config-get for examples. 2870 * @param string $value optional string (only for `SET`) 2871 * @return array Associative array for `GET`, key -> value 2872 * @link http://redis.io/commands/config-get 2873 * @link http://redis.io/commands/config-set 2874 * @example 2875 * <pre> 2876 * $redis->config("GET", "*max-*-entries*"); 2877 * $redis->config("SET", "dir", "/var/run/redis/dumps/"); 2878 * </pre> 2879 */ 2880 public function config( $operation, $key, $value ) {} 2881 2882 /** 2883 * @see eval() 2884 * @param string $script 2885 * @param array $args 2886 * @param int $numKeys 2887 */ 2888 public function evaluate( $script, $args = array(), $numKeys = 0 ) {} 2889 2890 /** 2891 * Evaluate a LUA script serverside, from the SHA1 hash of the script instead of the script itself. 2892 * In order to run this command Redis will have to have already loaded the script, either by running it or via 2893 * the SCRIPT LOAD command. 2894 * @param string $scriptSha 2895 * @param array $args 2896 * @param int $numKeys 2897 * @return mixed. @see eval() 2898 * @see eval() 2899 * @link http://redis.io/commands/evalsha 2900 * @example 2901 * <pre> 2902 * $script = ‘return 1‘; 2903 * $sha = $redis->script(‘load‘, $script); 2904 * $redis->evalSha($sha); // Returns 1 2905 * </pre> 2906 */ 2907 public function evalSha( $scriptSha, $args = array(), $numKeys = 0 ) {} 2908 2909 /** 2910 * @see evalSha() 2911 * @param string $scriptSha 2912 * @param array $args 2913 * @param int $numKeys 2914 */ 2915 public function evaluateSha( $scriptSha, $args = array(), $numKeys = 0 ) {} 2916 2917 /** 2918 * Execute the Redis SCRIPT command to perform various operations on the scripting subsystem. 2919 * @param string $command load | flush | kill | exists 2920 * @param string $script 2921 * @return mixed 2922 * @link http://redis.io/commands/script-load 2923 * @link http://redis.io/commands/script-kill 2924 * @link http://redis.io/commands/script-flush 2925 * @link http://redis.io/commands/script-exists 2926 * @example 2927 * <pre> 2928 * $redis->script(‘load‘, $script); 2929 * $redis->script(‘flush‘); 2930 * $redis->script(‘kill‘); 2931 * $redis->script(‘exists‘, $script1, [$script2, $script3, ...]); 2932 * </pre> 2933 * 2934 * SCRIPT LOAD will return the SHA1 hash of the passed script on success, and FALSE on failure. 2935 * SCRIPT FLUSH should always return TRUE 2936 * SCRIPT KILL will return true if a script was able to be killed and false if not 2937 * SCRIPT EXISTS will return an array with TRUE or FALSE for each passed script 2938 */ 2939 public function script( $command, $script ) {} 2940 2941 /** 2942 * The last error message (if any) 2943 * @return string A string with the last returned script based error message, or NULL if there is no error 2944 * @example 2945 * <pre> 2946 * $redis->eval(‘this-is-not-lua‘); 2947 * $err = $redis->getLastError(); 2948 * // "ERR Error compiling script (new function): user_script:1: ‘=‘ expected near ‘-‘" 2949 * </pre> 2950 */ 2951 public function getLastError() {} 2952 2953 /** 2954 * Clear the last error message 2955 * 2956 * @return bool true 2957 * @example 2958 * <pre> 2959 * $redis->set(‘x‘, ‘a‘); 2960 * $redis->incr(‘x‘); 2961 * $err = $redis->getLastError(); 2962 * // "ERR value is not an integer or out of range" 2963 * $redis->clearLastError(); 2964 * $err = $redis->getLastError(); 2965 * // NULL 2966 * </pre> 2967 */ 2968 public function clearLastError() {} 2969 2970 /** 2971 * A utility method to prefix the value with the prefix setting for phpredis. 2972 * @param $value The value you wish to prefix 2973 * @return string If a prefix is set up, the value now prefixed. If there is no prefix, the value will be returned unchanged. 2974 * @example 2975 * <pre> 2976 * $redis->setOption(Redis::OPT_PREFIX, ‘my-prefix:‘); 2977 * $redis->_prefix(‘my-value‘); // Will return ‘my-prefix:my-value‘ 2978 * </pre> 2979 */ 2980 public function _prefix( $value ) {} 2981 2982 /** 2983 * A utility method to unserialize data with whatever serializer is set up. If there is no serializer set, the 2984 * value will be returned unchanged. If there is a serializer set up, and the data passed in is malformed, an 2985 * exception will be thrown. This can be useful if phpredis is serializing values, and you return something from 2986 * redis in a LUA script that is serialized. 2987 * @param string $value The value to be unserialized 2988 * @return mixed 2989 * @example 2990 * <pre> 2991 * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); 2992 * $redis->_unserialize(‘a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}‘); // Will return Array(1,2,3) 2993 * </pre> 2994 */ 2995 public function _unserialize( $value ) {} 2996 2997 /** 2998 * Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command. 2999 * The data that comes out of DUMP is a binary representation of the key as Redis stores it. 3000 * @param string $key 3001 * @return string The Redis encoded value of the key, or FALSE if the key doesn‘t exist 3002 * @link http://redis.io/commands/dump 3003 * @example 3004 * <pre> 3005 * $redis->set(‘foo‘, ‘bar‘); 3006 * $val = $redis->dump(‘foo‘); // $val will be the Redis encoded key value 3007 * </pre> 3008 */ 3009 public function dump( $key ) {} 3010 3011 /** 3012 * Restore a key from the result of a DUMP operation. 3013 * 3014 * @param string $key The key name 3015 * @param int $ttl How long the key should live (if zero, no expire will be set on the key) 3016 * @param string $value (binary). The Redis encoded key value (from DUMP) 3017 * @return bool 3018 * @link http://redis.io/commands/restore 3019 * @example 3020 * <pre> 3021 * $redis->set(‘foo‘, ‘bar‘); 3022 * $val = $redis->dump(‘foo‘); 3023 * $redis->restore(‘bar‘, 0, $val); // The key ‘bar‘, will now be equal to the key ‘foo‘ 3024 * </pre> 3025 */ 3026 public function restore( $key, $ttl, $value ) {} 3027 3028 /** 3029 * Migrates a key to a different Redis instance. 3030 * 3031 * @param string $host The destination host 3032 * @param int $port The TCP port to connect to. 3033 * @param string $key The key to migrate. 3034 * @param int $db The target DB. 3035 * @param int $timeout The maximum amount of time given to this transfer. 3036 * @return bool 3037 * @link http://redis.io/commands/migrate 3038 * @example 3039 * <pre> 3040 * $redis->migrate(‘backup‘, 6379, ‘foo‘, 0, 3600); 3041 * </pre> 3042 */ 3043 public function migrate( $host, $port, $key, $db, $timeout ) {} 3044 3045 /** 3046 * Return the current Redis server time. 3047 * @return array If successfull, the time will come back as an associative array with element zero being the 3048 * unix timestamp, and element one being microseconds. 3049 * @link http://redis.io/commands/time 3050 * <pre> 3051 * var_dump( $redis->time() ); 3052 * // array(2) { 3053 * // [0] => string(10) "1342364352" 3054 * // [1] => string(6) "253002" 3055 * // } 3056 * </pre> 3057 */ 3058 public function time() {} 3059 } 3060 3061 class RedisException extends Exception {} 3062 3063 class RedisArray { 3064 /** 3065 * Constructor 3066 * 3067 * @param string $name Name of the redis array to create (required if using redis.ini to define array) 3068 * @param array $hosts Array of hosts to construct the array with 3069 * @param array $opts Array of options 3070 * @link https://github.com/nicolasff/phpredis/blob/master/arrays.markdown 3071 */ 3072 function __construct($name = ‘‘, array $hosts = NULL, array $opts = NULL) {} 3073 3074 /** 3075 * @return array list of hosts for the selected array 3076 */ 3077 public function _hosts() {} 3078 3079 /** 3080 * @return string the name of the function used to extract key parts during consistent hashing 3081 */ 3082 public function _function() {} 3083 3084 /** 3085 * @param string key The key for which you want to lookup the host 3086 * @return string the host to be used for a certain key 3087 */ 3088 public function _target($key) {} 3089 3090 /** 3091 * Use this function when a new node is added and keys need to be rehashed. 3092 */ 3093 public function _rehash() {} 3094 }
原文:http://www.cnblogs.com/lhat/p/6402472.html