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