Project

General

Profile

1
<?php
2

    
3
/*
4
 * This file is part of the Predis package.
5
 *
6
 * (c) Daniele Alessandri <suppakilla@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

    
12
require 'SharedConfigurations.php';
13

    
14
// Predis ships with a KeyPrefixProcessor class that is used to transparently
15
// prefix each key before sending commands to Redis, even for complex commands
16
// such as SORT, ZUNIONSTORE and ZINTERSTORE. Key prefixes are useful to create
17
// user-level namespaces for you keyspace, thus eliminating the need for separate
18
// logical databases.
19

    
20
$client = new Predis\Client($single_server, array('prefix' => 'nrk:'));
21

    
22
$client->mset(array('foo' => 'bar', 'lol' => 'wut'));
23
var_dump($client->mget('foo', 'lol'));
24
/*
25
array(2) {
26
  [0]=> string(3) "bar"
27
  [1]=> string(3) "wut"
28
}
29
*/
30

    
31
var_dump($client->keys('*'));
32
/*
33
array(2) {
34
  [0]=> string(7) "nrk:foo"
35
  [1]=> string(7) "nrk:lol"
36
}
37
*/
(3-3/17)