-
Notifications
You must be signed in to change notification settings - Fork 122
Open
Description
Summary
The default model_key_prefix currently includes the full module path (e.g., myapp.models.User), which can be problematic:
- Fragile to refactoring - Moving a model file or renaming a module breaks existing Redis keys
- Verbose keys - Keys become unnecessarily long
- Inconsistent with SQL ORMs - Most ORMs use just the class name for table names
Current behavior
class User(HashModel):
name: str
# Keys look like: myapp.models.User:abc123Proposed behavior
class User(HashModel):
name: str
# Keys would look like: User:abc123Considerations
This is a breaking change that requires careful handling:
- Existing keys would become orphaned after upgrade
- Two models with the same class name in different modules would collide
- Need migration path or documentation for users upgrading
Prior work
PR #522 attempted this change but was closed due to staleness. The implementation was simple (just use __name__ instead of __module__.__name__), but the migration/breaking change concerns need to be addressed.
Options
- Major version bump with clear migration docs
- Opt-in flag to use simplified prefix (non-breaking)
- Keep current behavior but improve documentation (Document
model_key_prefixusage #364)
Metadata
Metadata
Assignees
Labels
No labels