protected function validateKey($key)
    {
        if (!is_string($key)) {
            throw new CacheKeyException("Cache key must be a string, " . gettype($key) . " given");
        }

        if (preg_match("/[^A-Za-z0-9\._-]/", $key)) {
            throw new CacheKeyException("Cache key contains invalid characters: {$key}");
        }

        if (strlen($key) > 64) {
            throw new CacheKeyException("Cache key cannot be longer than 64 characters: {$key}");
        }
    }