StackExchange / StackExchange.Redis

General purpose redis client
https://stackexchange.github.io/StackExchange.Redis/
Other
5.89k stars 1.51k forks source link

add RedisChannel UseImplicitAutoPattern and IsPatternBased #2480

Closed mgravell closed 1 year ago

mgravell commented 1 year ago

fixes #2479 (option 1)

arteny commented 1 year ago

You marked string initialization of RedisChannel as Obsolete, but there is no any doumentation how to use new RedisChannel functions.

mgravell commented 1 year ago

The obsolete message literally gives that guidance, but yes we should check for any existing docs and update

arteny commented 1 year ago

The obsolete message literally gives that guidance, but yes we should check for any existing docs and update

A guidance? It raises questions only. Warning CS0618 'RedisChannel.implicit operator RedisChannel(string)' is obsolete: 'It is preferable to explicitly specify a PatternMode, or use the Literal/Pattern methods'

What is PatternMode and Literal/Pattern methods?

mgravell commented 1 year ago

I will revise the message, and improve the docs, but to give you an answer today: RwdisChannel.Literal / RedisChannel.Pattern, or the RedisChannel constructor that takes a PatternMode

arteny commented 1 year ago

ok, understood now, so instead of providing string key for subscribe, we need to use RedisChannel.Literal(key) or RedisChannel.Pattern(keysPattern) if using patterns

mgravell commented 1 year ago

You can still use a string if you eat the CS0618 - and if you want to use the old behaviour without the warning, the constructor (explicitly stating .Auto as the enum) achieves that. It is ambiguous though, and might not be advisable in all scenarios. The design is regretted, and we would prefer to make people ask themselves "am I subscribing to a single literal channel, or to a pattern of channels?"

jeffputz commented 1 year ago

Just getting around to a package update. This obsolete message still completely lacks context, and all I've been able to find is this PR, which is also absent intent of the change.

mgravell commented 1 year ago

I'll try to improve that. Short version:

jeffputz commented 1 year ago

@mgravell that makes sense, thank you. I think the missing context was that, until this, I wasn't aware that wildcards were possible in the pub/sub, so that's something new to me. I can't think of any situations where I would want to do that, but I suppose someone else could.

mgravell commented 1 year ago

Right; so use RedisChannel.Literal - job done

joshbartley commented 10 months ago

One part of the missing doc update is the redis backplane docs which use the obsolete string method.

https://learn.microsoft.com/en-us/aspnet/core/signalr/redis-backplane?view=aspnetcore-8.0

mgravell commented 10 months ago

I can take that, thanks