当前位置: 首页>>代码示例>>PHP>>正文


PHP BagOStuff::__construct方法代码示例

本文整理汇总了PHP中BagOStuff::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP BagOStuff::__construct方法的具体用法?PHP BagOStuff::__construct怎么用?PHP BagOStuff::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BagOStuff的用法示例。


在下文中一共展示了BagOStuff::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor. Parameters are:
  *   - server:      A server info structure in the format required by each
  *                  element in $wgDBServers.
  *
  *   - servers:     An array of server info structures describing a set of
  *                  database servers to distribute keys to. If this is
  *                  specified, the "server" option will be ignored.
  *
  *   - purgePeriod: The average number of object cache requests in between
  *                  garbage collection operations, where expired entries
  *                  are removed from the database. Or in other words, the
  *                  reciprocal of the probability of purging on any given
  *                  request. If this is set to zero, purging will never be
  *                  done.
  *
  *   - tableName:   The table name to use, default is "objectcache".
  *
  *   - shards:      The number of tables to use for data storage on each server.
  *                  If this is more than 1, table names will be formed in the style
  *                  objectcacheNNN where NNN is the shard index, between 0 and
  *                  shards-1. The number of digits will be the minimum number
  *                  required to hold the largest shard index. Data will be
  *                  distributed across all tables by key hash. This is for
  *                  MySQL bugs 61735 and 61736.
  *
  * @param array $params
  */
 public function __construct($params)
 {
     parent::__construct($params);
     if (isset($params['servers'])) {
         $this->serverInfos = $params['servers'];
         $this->numServers = count($this->serverInfos);
         $this->serverNames = array();
         foreach ($this->serverInfos as $i => $info) {
             $this->serverNames[$i] = isset($info['host']) ? $info['host'] : "#{$i}";
         }
     } elseif (isset($params['server'])) {
         $this->serverInfos = array($params['server']);
         $this->numServers = count($this->serverInfos);
     } else {
         $this->serverInfos = false;
         $this->numServers = 1;
     }
     if (isset($params['purgePeriod'])) {
         $this->purgePeriod = intval($params['purgePeriod']);
     }
     if (isset($params['tableName'])) {
         $this->tableName = $params['tableName'];
     }
     if (isset($params['shards'])) {
         $this->shards = intval($params['shards']);
     }
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:55,代码来源:SqlBagOStuff.php

示例2: isset

 /**
  * @param array $params Additional parameters include:
  *   - maxKeys : only allow this many keys (using oldest-first eviction)
  */
 function __construct($params = [])
 {
     parent::__construct($params);
     $this->maxCacheKeys = isset($params['maxKeys']) ? $params['maxKeys'] : INF;
     if ($this->maxCacheKeys <= 0) {
         throw new InvalidArgumentException('$maxKeys parameter must be above zero');
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:12,代码来源:HashBagOStuff.php

示例3: __construct

 /**
  * Constructor. Parameters are:
  *
  *   - caches:   This should have a numbered array of cache parameter
  *               structures, in the style required by $wgObjectCaches. See
  *               the documentation of $wgObjectCaches for more detail.
  *
  * @param array $params
  * @throws InvalidArgumentException
  */
 public function __construct($params)
 {
     parent::__construct($params);
     if (!isset($params['caches'])) {
         throw new InvalidArgumentException(__METHOD__ . ': the caches parameter is required');
     }
     $this->caches = array();
     foreach ($params['caches'] as $cacheInfo) {
         $this->caches[] = ObjectCache::newFromParams($cacheInfo);
     }
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:21,代码来源:MultiWriteBagOStuff.php

示例4: __construct

 /**
  * $params include:
  *   - caches:      This should have a numbered array of cache parameter
  *                  structures, in the style required by $wgObjectCaches. See
  *                  the documentation of $wgObjectCaches for more detail.
  *                  BagOStuff objects can also be used as values.
  *                  The first cache is the primary one, being the first to
  *                  be read in the fallback chain. Writes happen to all stores
  *                  in the order they are defined. However, lock()/unlock() calls
  *                  only use the primary store.
  *   - replication: Either 'sync' or 'async'. This controls whether writes to
  *                  secondary stores are deferred when possible. Async writes
  *                  require the HHVM register_postsend_function() function.
  *                  Async writes can increase the chance of some race conditions
  *                  or cause keys to expire seconds later than expected. It is
  *                  safe to use for modules when cached values: are immutable,
  *                  invalidation uses logical TTLs, invalidation uses etag/timestamp
  *                  validation against the DB, or merge() is used to handle races.
  *
  * @param array $params
  * @throws InvalidArgumentException
  */
 public function __construct($params)
 {
     parent::__construct($params);
     if (empty($params['caches']) || !is_array($params['caches'])) {
         throw new InvalidArgumentException(__METHOD__ . ': "caches" parameter must be an array of caches');
     }
     $this->caches = array();
     foreach ($params['caches'] as $cacheInfo) {
         $this->caches[] = $cacheInfo instanceof BagOStuff ? $cacheInfo : ObjectCache::newFromParams($cacheInfo);
     }
     $this->asyncWrites = isset($params['replication']) && $params['replication'] === 'async';
 }
开发者ID:ngertrudiz,项目名称:mediawiki,代码行数:34,代码来源:MultiWriteBagOStuff.php

示例5: __construct

 /**
  * Constructor. Parameters are:
  *   - writeFactory : ObjectFactory::getObjectFromSpec parameters yeilding BagOStuff.
  *                    This object will be used for writes (e.g. the master DB).
  *   - readFactory  : ObjectFactory::getObjectFromSpec parameters yeilding BagOStuff.
  *                    This object will be used for reads (e.g. a slave DB).
  *
  * @param array $params
  * @throws InvalidArgumentException
  */
 public function __construct($params)
 {
     parent::__construct($params);
     if (!isset($params['writeFactory'])) {
         throw new InvalidArgumentException(__METHOD__ . ': the "writeFactory" parameter is required');
     }
     if (!isset($params['readFactory'])) {
         throw new InvalidArgumentException(__METHOD__ . ': the "readFactory" parameter is required');
     }
     $this->writeStore = $params['writeFactory'] instanceof BagOStuff ? $params['writeFactory'] : ObjectFactory::getObjectFromSpec($params['writeFactory']);
     $this->readStore = $params['readFactory'] instanceof BagOStuff ? $params['readFactory'] : ObjectFactory::getObjectFromSpec($params['readFactory']);
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:22,代码来源:ReplicatedBagOStuff.php

示例6: __construct

 /**
  * Constructor. Parameters are:
  *   - writeFactory : ObjectFactory::getObjectFromSpec array yeilding BagOStuff.
  *                    This object will be used for writes (e.g. the master DB).
  *   - readFactory  : ObjectFactory::getObjectFromSpec array yeilding BagOStuff.
  *                    This object will be used for reads (e.g. a replica DB).
  *
  * @param array $params
  * @throws InvalidArgumentException
  */
 public function __construct($params)
 {
     parent::__construct($params);
     if (!isset($params['writeFactory'])) {
         throw new InvalidArgumentException(__METHOD__ . ': the "writeFactory" parameter is required');
     }
     if (!isset($params['readFactory'])) {
         throw new InvalidArgumentException(__METHOD__ . ': the "readFactory" parameter is required');
     }
     $opts = ['reportDupes' => false];
     // redundant
     $this->writeStore = $params['writeFactory'] instanceof BagOStuff ? $params['writeFactory'] : ObjectFactory::getObjectFromSpec($opts + $params['writeFactory']);
     $this->readStore = $params['readFactory'] instanceof BagOStuff ? $params['readFactory'] : ObjectFactory::getObjectFromSpec($opts + $params['readFactory']);
     $this->attrMap = $this->mergeFlagMaps([$this->readStore, $this->writeStore]);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:25,代码来源:ReplicatedBagOStuff.php

示例7: __construct

 public function __construct($params)
 {
     if (empty($params['url'])) {
         throw new InvalidArgumentException('URL parameter is required');
     }
     parent::__construct($params);
     if (empty($params['client'])) {
         $this->client = new MultiHttpClient([]);
     } else {
         $this->client = $params['client'];
     }
     // Make sure URL ends with /
     $this->url = rtrim($params['url'], '/') . '/';
     // Default config, R+W > N; no locks on reads though; writes go straight to state-machine
     $this->attrMap[self::ATTR_SYNCWRITES] = self::QOS_SYNCWRITES_QC;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:16,代码来源:RESTBagOStuff.php

示例8: __construct

 /**
  * Constructor
  *
  * Available parameters are:
  *   - nativeSerialize:     If true, pass objects to apc_store(), and trust it
  *                          to serialize them correctly. If false, serialize
  *                          all values in PHP.
  *
  * @param array $params
  */
 public function __construct(array $params = array())
 {
     parent::__construct($params);
     if (isset($params['nativeSerialize'])) {
         $this->nativeSerialize = $params['nativeSerialize'];
     } elseif (extension_loaded('apcu') && ini_get('apc.serializer') === 'default') {
         // APCu has a memory corruption bug when the serializer is set to 'default'.
         // See T120267, and upstream bug reports:
         //  - https://github.com/krakjoe/apcu/issues/38
         //  - https://github.com/krakjoe/apcu/issues/35
         //  - https://github.com/krakjoe/apcu/issues/111
         $this->logger->warning('The APCu extension is loaded and the apc.serializer INI setting ' . 'is set to "default". This can cause memory corruption! ' . 'You should change apc.serializer to "php" instead. ' . 'See <https://github.com/krakjoe/apcu/issues/38>.');
         $this->nativeSerialize = false;
     } else {
         $this->nativeSerialize = true;
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:27,代码来源:APCBagOStuff.php

示例9: array

 /**
  * Construct a RedisBagOStuff object. Parameters are:
  *
  *   - servers: An array of server names. A server name may be a hostname,
  *     a hostname/port combination or the absolute path of a UNIX socket.
  *     If a hostname is specified but no port, the standard port number
  *     6379 will be used. Required.
  *
  *   - connectTimeout: The timeout for new connections, in seconds. Optional,
  *     default is 1 second.
  *
  *   - persistent: Set this to true to allow connections to persist across
  *     multiple web requests. False by default.
  *
  *   - password: The authentication password, will be sent to Redis in
  *     clear text. Optional, if it is unspecified, no AUTH command will be
  *     sent.
  *
  *   - automaticFailover: If this is false, then each key will be mapped to
  *     a single server, and if that server is down, any requests for that key
  *     will fail. If this is true, a connection failure will cause the client
  *     to immediately try the next server in the list (as determined by a
  *     consistent hashing algorithm). True by default. This has the
  *     potential to create consistency issues if a server is slow enough to
  *     flap, for example if it is in swap death.
  * @param array $params
  */
 function __construct($params)
 {
     parent::__construct($params);
     $redisConf = array('serializer' => 'none');
     // manage that in this class
     foreach (array('connectTimeout', 'persistent', 'password') as $opt) {
         if (isset($params[$opt])) {
             $redisConf[$opt] = $params[$opt];
         }
     }
     $this->redisPool = RedisConnectionPool::singleton($redisConf);
     $this->servers = $params['servers'];
     if (isset($params['automaticFailover'])) {
         $this->automaticFailover = $params['automaticFailover'];
     } else {
         $this->automaticFailover = true;
     }
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:45,代码来源:RedisBagOStuff.php

示例10: foreach

 /**
  * Construct a RedisBagOStuff object. Parameters are:
  *
  *   - servers: An array of server names. A server name may be a hostname,
  *     a hostname/port combination or the absolute path of a UNIX socket.
  *     If a hostname is specified but no port, the standard port number
  *     6379 will be used. Arrays keys can be used to specify the tag to
  *     hash on in place of the host/port. Required.
  *
  *   - connectTimeout: The timeout for new connections, in seconds. Optional,
  *     default is 1 second.
  *
  *   - persistent: Set this to true to allow connections to persist across
  *     multiple web requests. False by default.
  *
  *   - password: The authentication password, will be sent to Redis in
  *     clear text. Optional, if it is unspecified, no AUTH command will be
  *     sent.
  *
  *   - automaticFailover: If this is false, then each key will be mapped to
  *     a single server, and if that server is down, any requests for that key
  *     will fail. If this is true, a connection failure will cause the client
  *     to immediately try the next server in the list (as determined by a
  *     consistent hashing algorithm). True by default. This has the
  *     potential to create consistency issues if a server is slow enough to
  *     flap, for example if it is in swap death.
  * @param array $params
  */
 function __construct($params)
 {
     parent::__construct($params);
     $redisConf = ['serializer' => 'none'];
     // manage that in this class
     foreach (['connectTimeout', 'persistent', 'password'] as $opt) {
         if (isset($params[$opt])) {
             $redisConf[$opt] = $params[$opt];
         }
     }
     $this->redisPool = RedisConnectionPool::singleton($redisConf);
     $this->servers = $params['servers'];
     foreach ($this->servers as $key => $server) {
         $this->serverTagMap[is_int($key) ? $server : $key] = $server;
     }
     if (isset($params['automaticFailover'])) {
         $this->automaticFailover = $params['automaticFailover'];
     } else {
         $this->automaticFailover = true;
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:49,代码来源:RedisBagOStuff.php

示例11: __construct

 /**
  * $params include:
  *   - caches: A numbered array of either ObjectFactory::getObjectFromSpec
  *      arrays yeilding BagOStuff objects or direct BagOStuff objects.
  *      If using the former, the 'args' field *must* be set.
  *      The first cache is the primary one, being the first to
  *      be read in the fallback chain. Writes happen to all stores
  *      in the order they are defined. However, lock()/unlock() calls
  *      only use the primary store.
  *   - replication: Either 'sync' or 'async'. This controls whether writes
  *      to secondary stores are deferred when possible. Async writes
  *      require setting 'asyncHandler'. HHVM register_postsend_function() function.
  *      Async writes can increase the chance of some race conditions
  *      or cause keys to expire seconds later than expected. It is
  *      safe to use for modules when cached values: are immutable,
  *      invalidation uses logical TTLs, invalidation uses etag/timestamp
  *      validation against the DB, or merge() is used to handle races.
  * @param array $params
  * @throws InvalidArgumentException
  */
 public function __construct($params)
 {
     parent::__construct($params);
     if (empty($params['caches']) || !is_array($params['caches'])) {
         throw new InvalidArgumentException(__METHOD__ . ': "caches" parameter must be an array of caches');
     }
     $this->caches = [];
     foreach ($params['caches'] as $cacheInfo) {
         if ($cacheInfo instanceof BagOStuff) {
             $this->caches[] = $cacheInfo;
         } else {
             if (!isset($cacheInfo['args'])) {
                 // B/C for when $cacheInfo was for ObjectCache::newFromParams().
                 // Callers intenting this to be for ObjectFactory::getObjectFromSpec
                 // should have set "args" per the docs above. Doings so avoids extra
                 // (likely harmless) params (factory/class/calls) ending up in "args".
                 $cacheInfo['args'] = [$cacheInfo];
             }
             $this->caches[] = ObjectFactory::getObjectFromSpec($cacheInfo);
         }
     }
     $this->asyncWrites = isset($params['replication']) && $params['replication'] === 'async' && is_callable($this->asyncHandler);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:43,代码来源:MultiWriteBagOStuff.php

示例12: array

 function __construct($params = array())
 {
     parent::__construct($params);
     $this->bag = array();
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:5,代码来源:HashBagOStuff.php

示例13: __construct

 /**
  * Constructor. Parameters are:
  *   - server:      A server info structure in the format required by each
  *                  element in $wgDBServers.
  *
  *   - servers:     An array of server info structures describing a set of database servers
  *                  to distribute keys to. If this is specified, the "server" option will be
  *                  ignored. If string keys are used, then they will be used for consistent
  *                  hashing *instead* of the host name (from the server config). This is useful
  *                  when a cluster is replicated to another site (with different host names)
  *                  but each server has a corresponding replica in the other cluster.
  *
  *   - purgePeriod: The average number of object cache requests in between
  *                  garbage collection operations, where expired entries
  *                  are removed from the database. Or in other words, the
  *                  reciprocal of the probability of purging on any given
  *                  request. If this is set to zero, purging will never be
  *                  done.
  *
  *   - tableName:   The table name to use, default is "objectcache".
  *
  *   - shards:      The number of tables to use for data storage on each server.
  *                  If this is more than 1, table names will be formed in the style
  *                  objectcacheNNN where NNN is the shard index, between 0 and
  *                  shards-1. The number of digits will be the minimum number
  *                  required to hold the largest shard index. Data will be
  *                  distributed across all tables by key hash. This is for
  *                  MySQL bugs 61735 and 61736.
  *   - slaveOnly:   Whether to only use replica DBs and avoid triggering
  *                  garbage collection logic of expired items. This only
  *                  makes sense if the primary DB is used and only if get()
  *                  calls will be used. This is used by ReplicatedBagOStuff.
  *   - syncTimeout: Max seconds to wait for replica DBs to catch up for WRITE_SYNC.
  *
  * @param array $params
  */
 public function __construct($params)
 {
     parent::__construct($params);
     $this->attrMap[self::ATTR_EMULATION] = self::QOS_EMULATION_SQL;
     $this->attrMap[self::ATTR_SYNCWRITES] = self::QOS_SYNCWRITES_NONE;
     if (isset($params['servers'])) {
         $this->serverInfos = [];
         $this->serverTags = [];
         $this->numServers = count($params['servers']);
         $index = 0;
         foreach ($params['servers'] as $tag => $info) {
             $this->serverInfos[$index] = $info;
             if (is_string($tag)) {
                 $this->serverTags[$index] = $tag;
             } else {
                 $this->serverTags[$index] = isset($info['host']) ? $info['host'] : "#{$index}";
             }
             ++$index;
         }
     } elseif (isset($params['server'])) {
         $this->serverInfos = [$params['server']];
         $this->numServers = count($this->serverInfos);
     } else {
         // Default to using the main wiki's database servers
         $this->serverInfos = false;
         $this->numServers = 1;
         $this->attrMap[self::ATTR_SYNCWRITES] = self::QOS_SYNCWRITES_BE;
     }
     if (isset($params['purgePeriod'])) {
         $this->purgePeriod = intval($params['purgePeriod']);
     }
     if (isset($params['tableName'])) {
         $this->tableName = $params['tableName'];
     }
     if (isset($params['shards'])) {
         $this->shards = intval($params['shards']);
     }
     if (isset($params['syncTimeout'])) {
         $this->syncTimeout = $params['syncTimeout'];
     }
     $this->replicaOnly = !empty($params['slaveOnly']);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:78,代码来源:SqlBagOStuff.php

示例14:

 function __construct(array $params)
 {
     parent::__construct($params);
     $this->attrMap[self::ATTR_SYNCWRITES] = self::QOS_SYNCWRITES_BE;
     // unreliable
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:6,代码来源:MemcachedBagOStuff.php

示例15: array

 /**
  * @param array $params Additional parameters include:
  *   - maxKeys : only allow this many keys (using oldest-first eviction)
  */
 function __construct($params = array())
 {
     parent::__construct($params);
     $this->maxCacheKeys = isset($params['maxKeys']) ? $params['maxKeys'] : INF;
     Assert::parameter($this->maxCacheKeys > 0, 'maxKeys', 'must be above zero');
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:10,代码来源:HashBagOStuff.php


注:本文中的BagOStuff::__construct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。