Skip to content

Feature: Key prefix - #292

Open
gliljas wants to merge 4 commits into
madelson:masterfrom
gliljas:keyprefix
Open

gliljas wants to merge 4 commits into
madelson:masterfrom
gliljas:keyprefix

Conversation

@gliljas

@gliljas gliljas commented Oct 19, 2026

Copy link
Copy Markdown

Modeled after the key prefix feature in StackExchange Redis

@gliljas gliljas changed the title Faeture: Key prefix Feature: Key prefix Nov 2, 2026
/// <param name="keyPrefix">The prefix to prepend to all lock names.</param>
/// <returns>A new <see cref="IDistributedLockProvider" /> that prepends <paramref name="keyPrefix" /> to all lock names.</returns>
/// <exception cref="ArgumentNullException"></exception>
public static IDistributedLockProvider WithKeyPrefix(this IDistributedLockProvider provider, string keyPrefix)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

WithNamePrefix would be a better fit with the rest of the library's naming conventions

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

@madelson

Copy link
Copy Markdown
Owner

Thanks for sharing @gliljas this is an interesting idea for the feature. The API is the tricky part: having multiple same-named extensions for different interfaces in different namespaces feels like it could easily confuse someone.

It's also unfortunate that applying this to, say, a SqlDistributedSynchronizationProvider will narrow it to just one type of provider, losing the other types.

We could implement this as new constructor option on all providers, but then you lose the ability to decorate an arbitrary provider.

It's possible that this is best as a user-land implementation, since a user who needs for any particular combination of the interfaces can easily build the decorator themselves.

I'll keep thinking about it. Open to other clever solutions as well.

@gliljas

gliljas commented Nov 16, 2026

Copy link
Copy Markdown
Author

Thanks for sharing @gliljas this is an interesting idea for the feature. The API is the tricky part: having multiple same-named extensions for different interfaces in different namespaces feels like it could easily confuse someone.

It's also unfortunate that applying this to, say, a SqlDistributedSynchronizationProvider will narrow it to just one type of provider, losing the other types.

I struggled to understand what you meant, but then I realized that you're referring to using the "SynchronizationProvider" as is, and not the abstractions it exposes.

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.

2 participants