示例#1
0
文件: Set.php 项目: utachkin/Rediska
 public function testIntersect()
 {
     $this->rediska->addToSet('test', 123);
     $this->rediska->addToSet('test', 456);
     $this->rediska->addToSet('test2', 123);
     $this->rediska->addToSet('test2', 789);
     $values = $this->set->intersect('test2');
     $this->assertEquals(array(123), $values);
     $values = $this->set->intersect(new Rediska_Key_Set('test2'));
     $this->assertEquals(array(123), $values);
     $values = $this->set->intersect(array('test2'));
     $this->assertEquals(array(123), $values);
 }
示例#2
0
 public function testIntersect()
 {
     $this->rediska->addToSortedSet('test', 123, 1);
     $this->rediska->addToSortedSet('test', 456, 2);
     $this->rediska->addToSortedSet('test2', 123, 3);
     $this->rediska->addToSortedSet('test2', 789, 4);
     $count = $this->set->intersect('test2', 'result');
     $this->assertEquals(1, $count);
     $values = $this->rediska->getSortedSet('result', true);
     $this->assertEquals(123, $values[0]->value);
     $this->assertEquals(4, $values[0]->score);
     $this->rediska->delete('result');
     $count = $this->set->intersect(new Rediska_Key_SortedSet('test2'), 'result', 'max');
     $this->assertEquals(1, $count);
     $values = $this->rediska->getSortedSet('result', true);
     $this->assertEquals(123, $values[0]->value);
     $this->assertEquals(3, $values[0]->score);
     $this->rediska->delete('result');
     $count = $this->set->intersect(array('test2'), 'result', 'min');
     $this->assertEquals(1, $count);
     $values = $this->rediska->getSortedSet('result', true);
     $this->assertEquals(123, $values[0]->value);
     $this->assertEquals(1, $values[0]->score);
     $this->rediska->delete('result');
     $count = $this->set->intersect(array('test2' => 2), 'result');
     $this->assertEquals(1, $count);
     $values = $this->rediska->getSortedSet('result', true);
     $this->assertEquals(123, $values[0]->value);
     $this->assertEquals(7, $values[0]->score);
 }