Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disambiguate cache key for similarly named models #140

Merged
merged 4 commits into from
Oct 7, 2024

Conversation

ahumeau
Copy link
Contributor

@ahumeau ahumeau commented Sep 12, 2024

Two models with the same name in different apps would previously get the same cache key.
Including the model's module in the cache key fixes this.

Two models with the same name in different apps would previously get the
same cache key.
Including the model's module in the cache key fixes this.
@johnthagen
Copy link
Collaborator

@ahumeau Could you provide a unit test?

@ahumeau
Copy link
Contributor Author

ahumeau commented Oct 7, 2024

@johnthagen sure :).
I just push them.

@johnthagen johnthagen self-assigned this Oct 7, 2024
@johnthagen johnthagen added the bug label Oct 7, 2024
@@ -64,7 +64,7 @@ def set_to_cache(self) -> None:
@classmethod
def get_cache_key(cls) -> str:
prefix = getattr(settings, "SOLO_CACHE_PREFIX", solo_settings.SOLO_CACHE_PREFIX)
return f"{prefix}:{cls.__name__.lower()}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment here that explains why we include cls.__module__?

Copy link
Collaborator

@johnthagen johnthagen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update CHANGES. You can add a line under

Unreleased
==========

@ahumeau ahumeau requested a review from johnthagen October 7, 2024 12:03
@johnthagen
Copy link
Collaborator

@ahumeau Thank you for your contribution.

@johnthagen johnthagen merged commit a83925e into lazybird:master Oct 7, 2024
5 checks passed
@ahumeau
Copy link
Contributor Author

ahumeau commented Oct 7, 2024

My pleasure, thanks for your work maintaining this project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants