Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 public function __construct($options)
 {
     parent::__construct($options);
     $this->cache = Di::getDefault()->getShared('cache');
     $this->cache instanceof Backend\File and $this->prefix = 'counter-';
 }