本文整理汇总了PHP中CacheEngine::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP CacheEngine::__construct方法的具体用法?PHP CacheEngine::__construct怎么用?PHP CacheEngine::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CacheEngine
的用法示例。
在下文中一共展示了CacheEngine::__construct方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(API $base, $key_prefix, $hostname, $port)
{
parent::__construct($key_prefix, $base);
if (!class_exists('Memcached')) {
throw new CoreException('Memcached PHP extension was not found');
}
$this->memcached = new \Memcached();
$this->memcached->addServer($hostname, $port);
}
示例2: __construct
public function __construct(API $base, $key_prefix, $hostname, $port)
{
parent::__construct($key_prefix, $base);
if (!class_exists('Redis')) {
throw new CoreException('Redis PHP extension (phpredis) was not found');
}
try {
$this->redis = new \Redis();
$this->redis->connect($hostname, $port);
$this->redis->select(0);
} catch (\RedisException $e) {
throw new CoreException("Redis failed: {$e->getMessage()}");
}
}
示例3: __construct
public function __construct(API $base, Database $database, $key_prefix)
{
parent::__construct($key_prefix, $base);
$this->database = $database;
if ($database instanceof MySQL) {
$sql = 'CREATE TABLE IF NOT EXISTS spindash_cache (item_key VARCHAR(255) NOT NULL, item_expires INT(11) UNSIGNED NOT NULL, item_value LONGTEXT NOT NULL, UNIQUE KEY (item_key)) ENGINE = InnoDB DEFAULT CHARSET=UTF8';
$database->exec($sql);
}
if ($database instanceof SQLite) {
$sql = 'CREATE TABLE IF NOT EXISTS spindash_cache (item_key TEXT, item_expires INTEGER, item_value TEXT, UNIQUE (item_key))';
$database->exec($sql);
}
if ($database instanceof PostgreSQL) {
$sql = 'CREATE TABLE IF NOT EXISTS spindash_cache (item_key VARCHAR(255) NOT NULL, item_expires INTEGER NOT NULL, item_value TEXT NOT NULL, UNIQUE (item_key))';
$database->exec($sql);
}
}