]>
Commit | Line | Data |
---|---|---|
ed9b544e | 1 | <?php |
2 | ||
3 | // poor man's tests | |
4 | ||
5 | require_once('redis.php'); | |
6 | ||
7 | $r =& new Redis('localhost'); | |
8 | $r->connect(); | |
bb7dcc1e | 9 | $r->select_db(9); |
8d03032a | 10 | $r->flushdb(); |
11 | echo "<pre>\n"; | |
ed9b544e | 12 | echo $r->ping() . "\n"; |
13 | echo $r->do_echo('ECHO test') . "\n"; | |
14 | echo "SET aaa " . $r->set('aaa', 'bbb') . "\n"; | |
15 | echo "SETNX aaa " . $r->set('aaa', 'ccc', true) . "\n"; | |
16 | echo "GET aaa " . $r->get('aaa') . "\n"; | |
17 | echo "INCR aaa " . $r->incr('aaa') . "\n"; | |
18 | echo "GET aaa " . $r->get('aaa') . "\n"; | |
19 | echo "INCRBY aaa 3 " . $r->incr('aaa', 2) . "\n"; | |
20 | echo "GET aaa " . $r->get('aaa') . "\n"; | |
21 | echo "DECR aaa " . $r->decr('aaa') . "\n"; | |
22 | echo "GET aaa " . $r->get('aaa') . "\n"; | |
23 | echo "DECRBY aaa 2 " . $r->decr('aaa', 2) . "\n"; | |
24 | echo "GET aaa " . $r->get('aaa') . "\n"; | |
25 | echo "EXISTS aaa " . $r->exists('aaa') . "\n"; | |
26 | echo "EXISTS fsfjslfjkls " . $r->exists('fsfjslfjkls') . "\n"; | |
27 | echo "DELETE aaa " . $r->delete('aaa') . "\n"; | |
28 | echo "EXISTS aaa " . $r->exists('aaa') . "\n"; | |
29 | echo 'SET a1 a2 a3' . $r->set('a1', 'a') . $r->set('a2', 'b') . $r->set('a3', 'c') . "\n"; | |
30 | echo 'KEYS a* ' . print_r($r->keys('a*'), true) . "\n"; | |
31 | echo 'RANDOMKEY ' . $r->randomkey('a*') . "\n"; | |
32 | echo 'RENAME a1 a0 ' . $r->rename('a1', 'a0') . "\n"; | |
8d03032a | 33 | echo 'RENAMENX a0 a2 ' . $r->renamenx('a0', 'a2') . "\n"; |
34 | echo 'RENAMENX a0 a1 ' . $r->renamenx('a0', 'a1') . "\n"; | |
ed9b544e | 35 | |
36 | echo 'LPUSH a0 aaa ' . $r->push('a0', 'aaa') . "\n"; | |
37 | echo 'LPUSH a0 bbb ' . $r->push('a0', 'bbb') . "\n"; | |
38 | echo 'RPUSH a0 ccc ' . $r->push('a0', 'ccc', false) . "\n"; | |
39 | echo 'LLEN a0 ' . $r->llen('a0') . "\n"; | |
40 | echo 'LRANGE sdkjhfskdjfh 0 100 ' . print_r($r->lrange('sdkjhfskdjfh', 0, 100), true) . "\n"; | |
8d03032a | 41 | echo 'LRANGE a0 0 0 ' . print_r($r->lrange('a0', 0, 0), true) . "\n"; |
ed9b544e | 42 | echo 'LRANGE a0 0 100 ' . print_r($r->lrange('a0', 0, 100), true) . "\n"; |
43 | echo 'LTRIM a0 0 1 ' . $r->ltrim('a0', 0, 1) . "\n"; | |
44 | echo 'LRANGE a0 0 100 ' . print_r($r->lrange('a0', 0, 100), true) . "\n"; | |
45 | echo 'LINDEX a0 0 ' . $r->lindex('a0', 0) . "\n"; | |
46 | echo 'LPUSH a0 bbb ' . $r->push('a0', 'bbb') . "\n"; | |
47 | echo 'LRANGE a0 0 100 ' . print_r($r->lrange('a0', 0, 100), true) . "\n"; | |
48 | echo 'RPOP a0 ' . $r->pop('a0') . "\n"; | |
49 | echo 'LPOP a0 ' . $r->pop('a0', false) . "\n"; | |
50 | echo 'LSET a0 ccc 0 ' . $r->lset('a0', 'ccc', 0) . "\n"; | |
51 | echo 'LRANGE a0 0 100 ' . print_r($r->lrange('a0', 0, 100), true) . "\n"; | |
52 | ||
53 | echo 'SADD s0 aaa ' . $r->sadd('s0', 'aaa') . "\n"; | |
54 | echo 'SADD s0 aaa ' . $r->sadd('s0', 'aaa') . "\n"; | |
55 | echo 'SADD s0 bbb ' . $r->sadd('s0', 'bbb') . "\n"; | |
56 | echo 'SREM s0 bbb ' . $r->srem('s0', 'bbb') . "\n"; | |
57 | echo 'SISMEMBER s0 aaa ' . $r->sismember('s0', 'aaa') . "\n"; | |
58 | echo 'SISMEMBER s0 bbb ' . $r->sismember('s0', 'bbb') . "\n"; | |
59 | echo 'SADD s0 bbb ' . $r->sadd('s0', 'bbb') . "\n"; | |
60 | echo 'SADD s1 bbb ' . $r->sadd('s1', 'bbb') . "\n"; | |
61 | echo 'SADD s1 aaa ' . $r->sadd('s1', 'aaa') . "\n"; | |
62 | echo 'SINTER s0 s1 ' . print_r($r->sinter(array('s0', 's1')), true) . "\n"; | |
63 | echo 'SREM s0 bbb ' . $r->srem('s0', 'bbb') . "\n"; | |
64 | echo 'SINTER s0 s1 ' . print_r($r->sinter(array('s0', 's1')), true) . "\n"; | |
65 | echo 'SMEMBERS s1 ' . print_r($r->smembers('s1'), true) . "\n"; | |
66 | ||
bb7dcc1e LM |
67 | echo 'SELECT 8 ' . $r->select_db(8) . "\n"; |
68 | echo 'EXISTS s1 ' . $r->exists('s1') . "\n"; | |
69 | if ($r->exists('s1')) | |
70 | echo 'SMEMBERS s1 ' . print_r($r->smembers('s1'), true) . "\n"; | |
71 | echo 'SELECT 9 ' . $r->select_db(9) . "\n"; | |
ed9b544e | 72 | echo 'SMEMBERS s1 ' . print_r($r->smembers('s1'), true) . "\n"; |
bb7dcc1e LM |
73 | echo 'MOVE s1 8 ' . $r->move('s1', 8) . "\n"; |
74 | echo 'EXISTS s1 ' . $r->exists('s1') . "\n"; | |
75 | if ($r->exists('s1')) | |
76 | echo 'SMEMBERS s1 ' . print_r($r->smembers('s1'), true) . "\n"; | |
77 | echo 'SELECT 8 ' . $r->select_db(8) . "\n"; | |
ed9b544e | 78 | echo 'SMEMBERS s1 ' . print_r($r->smembers('s1'), true) . "\n"; |
bb7dcc1e | 79 | echo 'SELECT 9 ' . $r->select_db(9) . "\n"; |
ed9b544e | 80 | |
81 | echo 'SAVE ' . $r->save() . "\n"; | |
82 | echo 'BGSAVE ' . $r->save(true) . "\n"; | |
83 | echo 'LASTSAVE ' . $r->lastsave() . "\n"; | |
84 | ||
bb7dcc1e | 85 | echo 'INFO ' . print_r($r->info()) . "\n"; |
8d03032a | 86 | echo "</pre>\n"; |
87 | ?> |