createCappedCollection() public method

public createCappedCollection ( string $name, integer $maxElements, integer $size ) : Collection
$name string name of collection
$maxElements integer The maximum number of elements to store in the collection.
$size integer Size in bytes.
return Collection
Example #1
0
 public function testCappedCollectionInsert()
 {
     $this->collection = $this->database->createCappedCollection('capped_collection', 3, 30);
     $this->collection->createDocument(array('param' => 1))->save();
     $this->collection->createDocument(array('param' => 2))->save();
     $this->collection->createDocument(array('param' => 3))->save();
     $this->collection->createDocument(array('param' => 4))->save();
     $this->assertEquals(3, $this->collection->find()->count());
     $documents = $this->collection->find();
     $this->assertEquals(2, $documents->current()->param);
     $documents->next();
     $this->assertEquals(3, $documents->current()->param);
     $documents->next();
     $this->assertEquals(4, $documents->current()->param);
     $this->collection->delete();
 }
Example #2
0
 /**
  * @expectedException Sokil\Mongo\Exception
  * @expectedExceptionMessage Size or number of elements must be defined
  */
 public function testCreateCappedCollection()
 {
     $this->database->createCappedCollection('collection', 'swong_size', 'wrong_number');
 }