feat(server): Allow configuration of hashtag extraction (#2890)

* feat(server): Allow configuration of hashtag extraction

Before this PR: Hashtags, if enabled, meant the text between `{` and `}`
in the key (if exists and non-empty).

After this PR:

* Hashtags can _still_ be enabled / disabled
* Hashtag open / close char can be specified (and can be the same), like `:` popular with BullMQ
* Hashtag can include `N` closing tags to skip, like `{a}b}c}d` with `2` will return `a}b}c`.

This will allow some existing systems to migrate without code changes in
client code.
This commit is contained in:
Shahar Mike 2024-04-14 15:09:41 +03:00 committed by GitHub
parent f6f7cfb2c9
commit 256e07f8ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 128 additions and 31 deletions

View file

@ -53,8 +53,16 @@ class CommandId;
class Transaction;
class EngineShard;
struct LockTagOptions {
bool enabled = false;
char open_locktag = '{';
char close_locktag = '}';
unsigned skip_n_end_delimiters = 0;
std::string prefix;
};
struct KeyLockArgs {
static bool IsLockHashTagEnabled();
static LockTagOptions GetLockTagOptions();
// Before acquiring and releasing keys, one must "normalize" them via GetLockKey().
static std::string_view GetLockKey(std::string_view key);