public function __construct($options) { parent::__construct($options); isset($options['table']) and $this->table = $options['table']; $db = Db::connection(); if (!$db->tableExists($this->table)) { $this->createTable(); } /* @var Dialect $dialect */ $dialect = $this->dialect = $db->getDialect(); $this->selectSql = $dialect->select(['tables' => [$this->table], 'columns' => ['value'], 'where' => $where = $dialect->escape('key') . ' = ?', 'forUpdate' => true]); $this->updateCondition = $where; }
public function __construct($options) { parent::__construct($options); $cacheType = Config::get('cache.default'); if ($cacheType == 'redis' || $cacheType == 'memcached') { $realAdapter = Cache::class; $this->realOptions = Config::get('counter.drivers.cache.options'); } else { $realAdapter = Rds::class; $this->realOptions = Config::get('counter.drivers.rds.options'); } // @codeCoverageIgnoreEnd $this->realCounter = new $realAdapter($this->realOptions); }
public function __construct($options) { parent::__construct($options); $this->cache = Di::getDefault()->getShared('cache'); $this->cache instanceof Backend\File and $this->prefix = 'counter-'; }