Return the length of a given list or set.

@param  string  $key
@param  string  $type
@return integer|\UnexpectedValueException
768610
public function length($key, $type = null)
	{
		if (is_null($type)) $type = $this->type($key);

		switch ($type)
		{
			case 'list':
				return $this->database->llen($key);

			case 'zset':
				return $this->database->zcard($key);

			default:
				throw new UnexpectedValueException("List type '{$type}' not supported.");
		}
	}
434033
public function getStringValue($key, $maxlength = null)
    {
        $value = $this->get($key);
        if ($value === null) {
            return null;
        }
        return ($maxlength === null) ? $value : substr($value, 0, $maxlength);
    }
1182092
public function getElementsWhichUseField($key, $type = "tt_content")
    {
        $storage = $this->storageRepository->load();

        $elementsInUse = array();
        if ($storage[$type]["elements"]) {
            foreach ($storage[$type]["elements"] as $element) {
                if ($element["columns"]) {
                    foreach ($element["columns"] as $column) {
                        if ($column == $key) {
                            $elementsInUse[] = $element;
                        }
                    }
                }
            }
        }
        return $elementsInUse;
    }
110031
public function lsize($key)
    {
        try {
            return $this->redis->lsize($key);
        } catch (\RedisException $e) {
            die("Error!: " . $e->getMessage() . "<br/>");
        }
    }
734074
public static function getBytes($key, $default = null): ?int
    {
        $value = ini_get($key);

        if ($value === false || $value === '') {
            return $default;
        }

        if ($value === '-1') {
            return -1;
        }

        $unit = preg_replace('/[^bkmgtpezy]/i', '', $value);
        $size = preg_replace('/[^0-9\.]/', '', $value);

        return ((int) $size) * ($unit ? pow(1024, mb_stripos('bkmgtpezy', $unit[0])) : 1);
    }
1014449
public function get($key, $type = self::NORMAL, $default = null)
    {
        $typeConfig = $this->getTypeConfig($type);

        if (array_key_exists($key, $typeConfig)) {
            return $typeConfig[$key];
        }

        return $default;
    }
615225
public function getValueByType($type)
    {
        $type = strtoupper($type);

        switch ($type) {
            case static::EAN:
                return $this->asEan();

            case static::ISBN10:
                return $this->asIsbn10();

            case static::ISBN13:
                return $this->asIsbn13();

            case static::UPC:
                return $this->asUpc();

            default:
                throw new Exception("Type {$type} not supported");
        }
    }
1364128
private static function getNumericKeyValue($key)
    {
        $newKey = \str_replace('np_serializer_element_', '', $key);
        list($type, $index) = \explode('_', $newKey);

        if ('integer' === $type) {
            $index = (int) $index;
        }

        return $index;
    }
1001031
public function getApiCalls(string $type = 'rest', string $key = null)
    {
        if ($key) {
            $keys = array_keys($this->apiCallLimits[$type]);
            if (!in_array($key, $keys)) {
                // No key like that in array
                throw new Exception('Invalid API call limit key. Valid keys are: '.implode(', ', $keys));
            }

            // Return the key value requested
            return $this->apiCallLimits[$type][$key];
        }

        // Return all the values
        return $this->apiCallLimits[$type];
    }
273669
protected function normalizeTypeAndLength($type)
    {
        if (empty($type)) {
            // @codeCoverageIgnoreStart
            return [null, null];
            // @codeCoverageIgnoreEnd
        }

        if (preg_match('#^(?<type>.*)\((?<length>\d+)\)$#', $type, $matches)) {
            return [ $this->normalizeType($matches['type']), (int) $matches['length'] ];
        }

        return [ $this->normalizeType($type), $this->getDefaultLengthForType($type) ];
    }
578548
public static function get($key,$type='sys')
    {
        /**
         * 获取缓存配置
         */
        self::$config = \Config::UNIVERSAL['cache'];

        /**
         * 初始化数据
         */
        self::$key = $key;

        $class = 'pizepei\model\cache\drive\\'.ucfirst(self::$config['driveType']);
        $class::$typeCache = $type;

        return $class::get(self::$key,self::$config);
    }
126954
public static function get($key = null, $type = 'string', $defaultValue = '')
    {
        if (!$key) {
            return $_GET;
        }
        return self::typeConvert(isset($_GET[$key]) ? $_GET[$key] : $defaultValue, $type);
    }
972309
private function hasData($type, $key)
    {
        return isset($this->data[$type]) && isset($this->data[$type][$key]);
    }
309671
private function canKeyBeUsedFor($type, JWKInterface $key)
    {
        if ($key->has('use')) {
            return $type === $key->get('use') ? 1 : false;
        }
        if ($key->has('key_ops')) {
            return $type === self::convertKeyOpsToKeyUse($key->get('use')) ? 1 : false;
        }

        return 0;
    }
414836
public function convertKey($key, $type)
    {
        $lines = [];

        if ($type == self::KEY_TYPE_PUBLIC) {
            $lines[] = '-----BEGIN PUBLIC KEY-----';
        } else {
            $lines[] = '-----BEGIN RSA PRIVATE KEY-----';
        }

        for ($i = 0; $i < strlen($key); $i += 64) {
            $lines[] = trim(substr($key, $i, 64));
        }

        if ($type == self::KEY_TYPE_PUBLIC) {
            $lines[] = '-----END PUBLIC KEY-----';
        } else {
            $lines[] = '-----END RSA PRIVATE KEY-----';
        }

        return implode("\n", $lines);
    }
58699
public function getType($key, $type)
    {
        if (is_array($key))
        {
            $args = $key;
        }
        else
        {
            $args = func_get_args();
            $type = array_pop($args); // Type
        }
        $val = $this->dget($args);

        if ($val === null)
            throw new \OutOfRangeException("Key " . implode('.', $args) . " does not exist");

        $checker = $type instanceof Type ? $type : new Type($type, ['unstrict' => true]);
        try
        {
            $value = $checker->filter($val);
        }
        catch (\InvalidArgumentException $e)
        {
            throw new \DomainException("Key " . implode('.', $args) . " is not " . (string)$checker);
        }

        return $value;
    }
213703
protected function hasItem($key, $type)
	{
		if(array_key_exists($type, $this->storage) && array_key_exists($key, $this->storage[$type]))
		{
			return true;
		}

		return false;
	}