StackExchange Redis ChannelPrefix Not Scoping Keys

别来无恙 提交于 2019-12-11 12:52:10

问题


I have channelPrefix declared in my connection string and I can tell by using ConfigurationOptions.Parse that it is correctly parsing out the channelPrefix from the string. I assumed that if I opened two instances of Microsoft.Extensions.Caching.StackExchangeRedis.RedisCache where they each had the same connection string, except for different channelPrefix values, that Redis would maintain separate values for the keys of the two, but that is not what I am seeing. When I set a value to a key using one instance of RedisCache, I can retrieve the value from the other instance using the same key. Am I totally misunderstanding what channelPrefix does or is it possible that our Redis server is configured in a way that does not obey channelPrefix?


回答1:


The concept of a "channel", and the RedisChannel type in particular, relates to the pub/sub API, not the keyspace DB API. For what you want, you are after the .WithKeyPrefix() extension method on the IDatabase that you obtained with GetDatabase().



来源:https://stackoverflow.com/questions/56859883/stackexchange-redis-channelprefix-not-scoping-keys

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!