# django.core.cache.backends.base.InvalidCacheKey: Cache key contains characters that will cause errors if used with memcached: "my key with spaces"

- **ID:** `python/django-cache-key-error`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

缓存键包含空格或特殊字符，memcached不支持

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   from django.core.cache import make_key; safe_key = make_key('my key with spaces')
   ```
2. **** (90% success)
   ```
   key = key.replace(' ', '_')
   ```

## Dead Ends

- **** — 缓存操作会失败，无法存取数据 (90% fail)
- **** — 长度不是问题，非法字符才是 (50% fail)
