File tree Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change 1+ // EXAMPLE: bf_tutorial
2+ <?php
3+
4+ require 'vendor/autoload.php ' ;
5+
6+ use Predis \Client as PredisClient ;
7+
8+ class DtBloomTest
9+ // REMOVE_START
10+ extends PredisTestCase
11+ // REMOVE_END
12+ {
13+ public function testDtBloom () {
14+ $ r = new PredisClient ([
15+ 'scheme ' => 'tcp ' ,
16+ 'host ' => '127.0.0.1 ' ,
17+ 'port ' => 6379 ,
18+ 'password ' => '' ,
19+ 'database ' => 0 ,
20+ ]);
21+ // REMOVE_START
22+ $ r ->flushall ();
23+ // REMOVE_END
24+
25+ // STEP_START bloom
26+ $ res1 = $ r ->bfreserve ('bikes:models ' , 0.01 , 1000 );
27+ echo $ res1 . PHP_EOL ;
28+ // >>> OK
29+
30+ $ res2 = $ r ->bfadd ('bikes:models ' , 'Smoky Mountain Striker ' );
31+ echo $ res2 . PHP_EOL ;
32+ // >>> 1
33+
34+ $ res3 = $ r ->bfexists ('bikes:models ' , 'Smoky Mountain Striker ' );
35+ echo $ res3 . PHP_EOL ;
36+ // >>> 1
37+
38+ $ res4 = $ r ->bfmadd (
39+ 'bikes:models ' ,
40+ 'Rocky Mountain Racer ' ,
41+ 'Cloudy City Cruiser ' ,
42+ 'Windy City Wippet '
43+ );
44+ echo json_encode ($ res4 ) . PHP_EOL ;
45+ // >>> [1,1,1]
46+
47+ $ res5 = $ r ->bfmexists (
48+ 'bikes:models ' ,
49+ 'Rocky Mountain Racer ' ,
50+ 'Cloudy City Cruiser ' ,
51+ 'Windy City Wippet '
52+ );
53+ echo json_encode ($ res5 ) . PHP_EOL ;
54+ // >>> [1,1,1]
55+ // STEP_END
56+ // REMOVE_START
57+ $ this ->assertEquals ('OK ' , $ res1 );
58+ $ this ->assertEquals (1 , $ res2 );
59+ $ this ->assertEquals (1 , $ res3 );
60+ $ this ->assertEquals ([1 ,1 ,1 ], $ res4 );
61+ $ this ->assertEquals ([1 ,1 ,1 ], $ res5 );
62+ // REMOVE_END
63+ }
64+ }
65+
You can’t perform that action at this time.
0 commit comments