redis key_formatter should handle cases where client keys contain hash tag
Title: redis key_formatter should handle cases where client keys contain hash tag
Description:
Redis supports hash tag feature which can be used to to take a curly braces wrapped substring for key hash.
Consider a scenario where user specify a key_formatter that uses hash tag, e.g. prefix-{%KEY%}, and the client key contains hash tag as well, e.g. foo-{bar}. The formatted key becomes prefix-{foo-{bar}} and foo-{bar will be used for hash instead ofbar intended by client.
The proposed change is to add an option for key_formatter to prefer client key's hash tag if present. If the feature is enabled and the first pair of curly braces in key_formatter wraps %KEY% which also contains hash tag, the key_formatter will be stripped off of the pair of curly braces. In the above example, the formatted key becomes prefix-foo-{bar}.
[optional Relevant Links:] redis hash tag
CC @ramaraochavali @deveshkandpal1224
@msukalski @henryyyang @mattklein123 @weisisea
Is there a reason not to do it by default? Do we need a config? If you are worried about BC, may be a runtime flag is fine - not sure it is worth any api change?
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.
I feel like this should be done in an API field validation rather than trying to handle at the formatter implementation. like for example reject if a curly bracket is present in the key_formatter string in the first place, or at least print a warning like that would break the intended hash tag use by the client.