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