コード例 #1
0
ファイル: APC.php プロジェクト: shabbyrobe/cachet
 function value($key)
 {
     $formattedKey = \Cachet\Helper::formatKey([$this->prefix, $this->cacheId, $key]);
     $value = apc_fetch($formattedKey);
     if (!is_numeric($value) && !is_bool($value) && $value !== null) {
         $type = \Cachet\Helper::getType($value);
         throw new \UnexpectedValueException("APC counter expected numeric value, found {$type} at key {$key}");
     }
     return $value ?: 0;
 }
コード例 #2
0
ファイル: XCache.php プロジェクト: shabbyrobe/cachet
 function value($key)
 {
     $formatted = \Cachet\Helper::formatKey([$this->prefix, 'counter', $key]);
     $value = xcache_get($formatted);
     if (!is_numeric($value) && !is_bool($value) && $value !== null) {
         $type = \Cachet\Helper::getType($value);
         throw new \UnexpectedValueException("XCache counter expected numeric value, found {$type} at key {$key}");
     }
     return (int) $value ?: 0;
 }
コード例 #3
0
ファイル: PHPRedis.php プロジェクト: shabbyrobe/cachet
 function value($key)
 {
     $redis = $this->connector->redis ?: $this->connector->connect();
     $key = \Cachet\Helper::formatKey([$this->prefix, 'counter', $key]);
     $value = $redis->get($key);
     if (!is_numeric($value) && !is_bool($value) && $value !== null) {
         $type = \Cachet\Helper::getType($value);
         throw new \UnexpectedValueException("Redis counter expected numeric value, found {$type} at key {$key}");
     }
     return (int) $value ?: 0;
 }
コード例 #4
0
ファイル: PDO.php プロジェクト: shabbyrobe/cachet
 public function __construct($dbInfo)
 {
     if (is_string($dbInfo)) {
         $dbInfo = ['dsn' => $dbInfo];
     }
     if (is_array($dbInfo)) {
         $this->params = $dbInfo;
     } elseif (is_callable($dbInfo)) {
         $this->creatorCallback = $dbInfo;
     } elseif (is_object($dbInfo)) {
         $this->pdo = $dbInfo;
         $this->engine = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME);
     } else {
         throw new \InvalidArgumentException("Must pass a connection info array, a callback that returns a PDO " . "or a PDO instance, found " . \Cachet\Helper::getType($dbInfo));
     }
 }
コード例 #5
0
ファイル: Memcache.php プロジェクト: shabbyrobe/cachet
 private function ensureValidValue($memcache, $formattedKey, $value)
 {
     if (!is_numeric($value) && !is_bool($value) && $value !== null) {
         $type = \Cachet\Helper::getType($value);
         throw new \UnexpectedValueException("Memcache counter expected numeric value, found {$type} at key {$key}");
     }
 }