Cache\Adapter\MongoDB\MongoDBCachePool::createCollection PHP Method

createCollection() public static method

public static createCollection ( MongoDB\Driver\Manager $manager, string $database, string $collection ) : MongoDB\Collection
$manager MongoDB\Driver\Manager
$database string
$collection string
return MongoDB\Collection
    public static function createCollection(Manager $manager, $database, $collection)
    {
        $collection = new Collection($manager, $database, $collection);
        $collection->createIndex(['expireAt' => 1], ['expireAfterSeconds' => 0]);
        return $collection;
    }

Usage Example

 public function createCachePool()
 {
     $manager = new Manager("mongodb://" . getenv('MONGODB_HOST'));
     // In your own code, only do this *once* to initialize your cache
     $collection = MongoDBCachePool::createCollection($manager, getenv('MONGODB_COLLECTION'));
     return new MongoDBCachePool($collection);
 }
All Usage Examples Of Cache\Adapter\MongoDB\MongoDBCachePool::createCollection