Mongo::setPoolSize
(PECL mongo >=1.2.0)
Mongo::setPoolSize — Set the size for future connection pools.
Описание
$size
)This method has been DEPRECATED as of version 1.2.3. Relying on this feature is highly discouraged. Please use MongoPool::setSize() instead.
Sets the max number of connections new pools will be able to create.
Список параметров
-
size
-
The max number of connections future pools will be able to create. Negative numbers mean that the pool will spawn an infinite number of connections.
Возвращаемые значения
Returns the former value of pool size.
Примеры
Пример #1 Mongo::setPoolSize() example
If you set the pool size to n and then create n connections, attempting to create an n+1st connection will throw a MongoConnectionException.
<?php
// only allow one connection to a server
Mongo::setPoolSize(1);
// creates one connection to localhost:27017
$m1 = new Mongo();
// attempt to create a second connection to localhost:27017
// only one connection is allowed, so this will throw an exception
$m2 = new Mongo();
?>
Результатом выполнения данного примера будет что-то подобное:
Fatal error: Uncaught exception 'MongoConnectionException' with message 'no more connections in pool' in /path/to/php/script.php:10 Stack trace: #0 /path/to/php/script.php(10): Mongo->__construct() #1 {main} thrown in /path/to/php/script.php on line 10
Смотрите также
- Mongo::getPoolSize() - Get pool size for connection pools
- Mongo::poolDebug() - Returns information about all connection pools.
- The connection documentation.
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- MongoDB
- Дополнительно
- Функция Mongo::connectUtil() - Connects with a database server
- Функция Mongo::__construct() - The __construct purpose
- Функция Mongo::getPoolSize() - Get pool size for connection pools
- Функция Mongo::getSlave() - Returns the address being used by this for slaveOkay reads
- Функция Mongo::getSlaveOkay() - Get slaveOkay setting for this connection
- Функция Mongo::poolDebug() - Returns information about all connection pools.
- Функция Mongo::setPoolSize() - Set the size for future connection pools.
- Функция Mongo::setSlaveOkay() - Change slaveOkay setting for this connection
- Функция Mongo::switchSlave() - Choose a new secondary for slaveOkay reads
Коментарии
404 Not Found