Consider simplifying default model_key_prefix
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.3k
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
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:abc123
Proposed behavior
class User(HashModel):
name: str
# Keys would look like: User:abc123
Considerations
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 (#364)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing model_key_prefix implementation and PR #522, then examine how Redis keys are generated and how migrations or compatibility are documented. The issue has no selected option or named files, so done requires deciding whether to change the default, add an opt-in path, or retain the behavior with improved documentation, including a migration strategy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, redis
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100