Skip to content

Conversation

jvanasco
Copy link
Member

@jvanasco jvanasco commented Sep 12, 2025

Extends Redis/Valkey with a "lock_prefix" argument, which allows users to override the default "_lock{0}" template.

I proposed this 10 years ago, and have been using it in a custom backend. I keep forgetting to turn this into a PR.

The rationale for this PR: The current design uses a template of "_lock{0}" % key which can be visually confusing to scan during manual audits: _lockkey1, _lockkey2, etc. This PR allows for "_lok.{0}" % key, which is easier to read: _lok.key1, _lok.key2, etc.

A regex is used to validate the lock_prefix, restricting it to 2-10 chars [A-Z0-9_-:.]

A test for correct usage is provided. Because the test system uses setupclass, I could not think of a good way to implement bad config args.

Fixes: #76
Change-Id: I22a6776168c78030e4472591a0c1e12a45b67cfb

…s to override the default "_lock{0}" template.

Fixes: 76
Change-Id: I22a6776168c78030e4472591a0c1e12a45b67cfb
@zzzeek zzzeek requested a review from sqla-tester September 16, 2025 13:56
Copy link
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

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

OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision dda8fff of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Collaborator

New Gerrit review created for change dda8fff: https://gerrit.sqlalchemy.org/c/sqlalchemy/dogpile.cache/+/6116

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

Successfully merging this pull request may close these issues.

.6x suggestion - change redis lock keys
2 participants