StackExchange.Redis.Extensions icon indicating copy to clipboard operation
StackExchange.Redis.Extensions copied to clipboard

Channel name is prefixed twice when RedisConfiguration.KeyPrefix is set

Open jswiniarski opened this issue 5 years ago • 1 comments

Hi, We use Redis extensions with KeyPrefix configured. I noticed that when PUBLISH is invoked, channel name sent to Redis has double prefix.

To Reproduce Run following code

var conf = new RedisConfiguration
{
    Hosts = new []{ new RedisHost{Host = "localhost", Port = 6379}, },
    KeyPrefix = "AAA-"
};
var pool = new RedisCacheConnectionPoolManager(conf);
var serializer = new NewtonsoftSerializer();
var client = new RedisCacheClient(pool, serializer, conf);
var db = client.GetDbFromConfiguration().Database;

// this set 'AAA-key'
db.StringSet("key", "value");

// this publishes to 'AAA-AAA-channel'
db.Publish("channel", "message");

and subscribe to Redis using CLI issuing PSUBSCRIBE * command. Output is

127.0.0.1:6379[3]> PSUBSCRIBE *
Reading messages... (press Ctrl-C to quit)
1) "psubscribe"
2) "*"
3) (integer) 1
1) "pmessage"
2) "*"
3) "AAA-AAA-channel"
4) "message"

Expected behavior Channel name should be prefixed only once.

Desktop (please complete the following information):

  • OS: Windows 10
  • Runtime version .NET Framework, .NET Core 3.1.102
  • Version
    • StackExchange.Redis.Extensions.Core Version 6.3.4
    • StackExchange.Redis 2.1.58

Possibly caused by #197

jswiniarski avatar Jul 31 '20 19:07 jswiniarski

Just check with plain StackExchange.Redis and it works ok:

var conf = new ConfigurationOptions
{
    ChannelPrefix = "AAA-",
    EndPoints = {"localhost:6379"}
};

var con = ConnectionMultiplexer.Connect(conf);
con.GetDatabase().Publish("channel", "message"); 

on subscriber side:

1) "pmessage"
2) "*"
3) "AAA-channel"
4) "message"

jswiniarski avatar Jul 31 '20 19:07 jswiniarski