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); }
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()}"); } }
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); } }