redis / redis/redis-om-python

Consider simplifying default model_key_prefix

Open
#741 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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:

  1. Fragile to refactoring - Moving a model file or renaming a module breaks existing Redis keys
  2. Verbose keys - Keys become unnecessarily long
  3. 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

  1. Major version bump with clear migration docs
  2. Opt-in flag to use simplified prefix (non-breaking)
  3. Keep current behavior but improve documentation (#364)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.