本文整理汇总了PHP中Zend\Cache\Storage\Adapter\AbstractAdapter::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractAdapter::__construct方法的具体用法?PHP AbstractAdapter::__construct怎么用?PHP AbstractAdapter::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Cache\Storage\Adapter\AbstractAdapter
的用法示例。
在下文中一共展示了AbstractAdapter::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param null|array|Traversable|DbaOptions $options
* @throws Exception\ExceptionInterface
*/
public function __construct($options = null)
{
if (!extension_loaded('dba')) {
throw new Exception\ExtensionNotLoadedException('Missing ext/dba');
}
parent::__construct($options);
}
示例2: __construct
/**
* @param null $options
*/
public function __construct($options = null)
{
parent::__construct($options);
// reset initialized flag on update option(s)
$initialized =& $this->initialized;
$this->getEventManager()->attach('option', function ($event) use(&$initialized) {
$initialized = false;
});
}
示例3: __construct
/**
* Constructor
*
* @param null|array|Traversable|ApcuOptions $options
* @throws Exception\ExceptionInterface
*/
public function __construct($options = null)
{
if (version_compare(phpversion('apcu'), '5.1.0', '<')) {
throw new Exception\ExtensionNotLoadedException('Missing ext/apcu >= 5.1.0');
}
if (!ini_get('apc.enabled') || PHP_SAPI === 'cli' && !ini_get('apc.enable_cli')) {
throw new Exception\ExtensionNotLoadedException("ext/apcu is disabled - see 'apc.enabled' and 'apc.enable_cli'");
}
parent::__construct($options);
}
示例4: __construct
/**
* {@inheritDoc}
*
* @throws Exception\ExtensionNotLoadedException
*/
public function __construct($options = null)
{
if (!class_exists('Mongo') || !class_exists('MongoClient')) {
throw new Exception\ExtensionNotLoadedException('MongoDb extension not loaded or Mongo polyfill not included');
}
parent::__construct($options);
$initialized =& $this->initialized;
$this->getEventManager()->attach('option', function () use(&$initialized) {
$initialized = false;
});
}
示例5: __construct
/**
* Constructor
*
* @param null|array|Traversable|MemcachedOptions $options
* @throws Exception\ExceptionInterface
*/
public function __construct($options = null)
{
if (static::$extMemcachedMajorVersion === null) {
$v = (string) phpversion('memcached');
static::$extMemcachedMajorVersion = $v !== '' ? (int) $v[0] : 0;
}
if (static::$extMemcachedMajorVersion < 1) {
throw new Exception\ExtensionNotLoadedException('Need ext/memcached version >= 1.0.0');
}
parent::__construct($options);
}
示例6: __construct
/**
* Constructor
*
* @param null|array|Traversable|ApcOptions $options
* @throws Exception\ExceptionInterface
*/
public function __construct($options = null)
{
$enabled = ini_get('apc.enabled');
if (PHP_SAPI == 'cli') {
$enabled = $enabled && (bool) ini_get('apc.enable_cli');
}
if (!$enabled) {
throw new Exception\ExtensionNotLoadedException("ext/apc is disabled - see 'apc.enabled' and 'apc.enable_cli'");
}
parent::__construct($options);
}
示例7: __construct
/**
* Constructor
*
* @param null|array|Traversable|MemcachedOptions $options
* @throws Exception\ExceptionInterface
*/
public function __construct($options = null)
{
if (phpversion('memcached') < 1) {
throw new Exception\ExtensionNotLoadedException('Need ext/memcached version >= 1.0.0');
}
parent::__construct($options);
// reset initialized flag on update option(s)
$initialized =& $this->initialized;
$this->getEventManager()->attach('option', function () use(&$initialized) {
$initialized = false;
});
}
示例8: __construct
/**
* Constructor
*
* @param null|array|Traversable|MemcachedOptions $options
* @throws Exception\ExceptionInterface
* @return void
*/
public function __construct($options = null)
{
if (static::$extMemcachedMajorVersion === null) {
$v = (string) phpversion('memcached');
static::$extMemcachedMajorVersion = ($v !== '') ? (int)$v[0] : 0;
}
if (static::$extMemcachedMajorVersion < 1) {
throw new Exception\ExtensionNotLoadedException('Need ext/memcached version >= 1.0.0');
}
parent::__construct($options);
// It's ok to init the memcached instance as soon as possible because
// ext/memcached auto-connects to the server on first use
$this->memcached = new MemcachedResource();
$options = $this->getOptions();
// set lib options
if (static::$extMemcachedMajorVersion > 1) {
$this->memcached->setOptions($options->getLibOptions());
} else {
foreach ($options->getLibOptions() as $k => $v) {
$this->memcached->setOption($k, $v);
}
}
$servers = $options->getServers();
if (!$servers) {
$options->addServer('127.0.0.1', 11211);
$servers = $options->getServers();
}
$this->memcached->addServers($servers);
// get notified on change options
$memc = $this->memcached;
$memcMV = static::$extMemcachedMajorVersion;
$this->events()->attach('option', function ($event) use ($memc, $memcMV) {
$params = $event->getParams();
if (isset($params['lib_options'])) {
if ($memcMV > 1) {
$memc->setOptions($params['lib_options']);
} else {
foreach ($params['lib_options'] as $k => $v) {
$memc->setOption($k, $v);
}
}
}
// TODO: update on change/add server(s)
});
}
示例9: __construct
/**
* Constructor
*
* @param null|array|Traversable|MemcacheOptions $options
* @throws Exception\ExceptionInterface
*/
public function __construct($options = null)
{
if (version_compare('2.0.0', phpversion('memcache')) > 0) {
throw new Exception\ExtensionNotLoadedException("Missing ext/memcache version >= 2.0.0");
}
parent::__construct($options);
// reset initialized flag on update option(s)
$initialized =& $this->initialized;
$this->getEventManager()->attach('option', function () use(&$initialized) {
$initialized = false;
});
}
示例10: __construct
/**
* Create new Adapter for redis storage
*
* @param null|array|Traversable|RedisArrayOptions $options
* @see \Zend\Cache\Storage\Adapter\Abstract
*/
public function __construct($options = null)
{
if (!extension_loaded('redis')) {
throw new Exception\ExtensionNotLoadedException("Redis extension is not loaded");
}
parent::__construct($options);
// reset initialized flag on update option(s)
$initialized =& $this->initialized;
$this->getEventManager()->attach('option', function ($event) use(&$initialized) {
$initialized = false;
});
}
示例11: __construct
/**
* Constructor
*
* @param null|array|Traversable|XCacheOptions $options
* @throws Exception\ExceptionInterface
*/
public function __construct($options = null)
{
if (!extension_loaded('xcache')) {
throw new Exception\ExtensionNotLoadedException('Missing ext/xcache');
}
if (PHP_SAPI == 'cli') {
throw new Exception\ExtensionNotLoadedException("ext/xcache isn't available on SAPI 'cli'");
}
if (ini_get('xcache.var_size') <= 0) {
throw new Exception\ExtensionNotLoadedException("ext/xcache is disabled - see 'xcache.var_size'");
}
parent::__construct($options);
}
示例12: __construct
/**
* Constructor
*
* @param null|array|Traversable|ApcOptions $options
* @throws Exception\ExceptionInterface
*/
public function __construct($options = null)
{
if (version_compare('3.1.6', phpversion('apc')) > 0) {
throw new Exception\ExtensionNotLoadedException("Missing ext/apc >= 3.1.6");
}
$enabled = ini_get('apc.enabled');
if (PHP_SAPI == 'cli') {
$enabled = $enabled && (bool) ini_get('apc.enable_cli');
}
if (!$enabled) {
throw new Exception\ExtensionNotLoadedException("ext/apc is disabled - see 'apc.enabled' and 'apc.enable_cli'");
}
parent::__construct($options);
}
示例13: __construct
/**
* Constructor
*
* @param array|Traversable|WinCacheOptions $options
* @throws Exception\ExceptionInterface
*/
public function __construct($options = null)
{
if (!extension_loaded('wincache')) {
throw new Exception\ExtensionNotLoadedException("WinCache extension is not loaded");
}
$enabled = ini_get('wincache.ucenabled');
if (PHP_SAPI == 'cli') {
$enabled = $enabled && (bool) ini_get('wincache.enablecli');
}
if (!$enabled) {
throw new Exception\ExtensionNotLoadedException("WinCache is disabled - see 'wincache.ucenabled' and 'wincache.enablecli'");
}
parent::__construct($options);
}
示例14: __construct
/**
* Constructor
*
* @param null|array|Traversable|MemcachedOptions $options
* @throws Exception\ExceptionInterface
*/
public function __construct($options = null)
{
if (static::$extMemcachedMajorVersion === null) {
$v = (string) phpversion('memcached');
static::$extMemcachedMajorVersion = $v !== '' ? (int) $v[0] : 0;
}
if (static::$extMemcachedMajorVersion < 1) {
throw new Exception\ExtensionNotLoadedException('Need ext/memcached version >= 1.0.0');
}
parent::__construct($options);
// reset initialized flag on update option(s)
$initialized =& $this->initialized;
$this->getEventManager()->attach('option', function ($event) use(&$initialized) {
$initialized = false;
});
}
示例15: __construct
/**
* Constructor
*
* @param null|array|Traversable|MemcachedOptions $options
* @throws Exception
* @return void
*/
public function __construct($options = null)
{
if (static::$extMemcachedMajorVersion === null) {
$v = (string) phpversion('memcached');
static::$extMemcachedMajorVersion = $v !== '' ? (int) $v[0] : 0;
}
if (static::$extMemcachedMajorVersion < 1) {
throw new Exception\ExtensionNotLoadedException('Need ext/memcached version >= 1.0.0');
}
$this->memcached = new MemcachedResource();
parent::__construct($options);
// It's ok to add server as soon as possible because
// ext/memcached auto-connects to the server on first use
// TODO: Handle multiple servers
$options = $this->getOptions();
$this->memcached->addServer($options->getServer(), $options->getPort());
}