2881099 / FreeRedis

🦄 FreeRedis is .NET40+ redis client. supports cluster, sentinel, master-slave, pub-sub, lua, pipeline, transaction, streams, client-side-caching, and pooling.
MIT License
911 stars 160 forks source link

FIX: #172 修复了集群模式下 使用非Ascii字符作为Key时错误的Slot计算带来的Moved报错问题 #174

Closed eveloki closed 8 months ago

eveloki commented 8 months ago

FIX:https://github.com/2881099/FreeRedis/issues/172 为GetClusterSlot的静态方法添加一个Encoding入参默认为Encoding.ASCII,这样能兼容之前的写法,并且在ClusterAdapter初始化时获取当前实例的Encoding,这样符合链接字符串设计,缓存_baseEncoding是为了简化反复从_clusterConnectionStrings中获取。并且这样只需要在ClusterAdapter的GetRedisSocket中传入当前实例的Encoding,就不会污染其他实现,比如NormanAdapter

eveloki commented 8 months ago

GetClusterSlot方法为静态方法,如果全局出现了不同编码的两个实例(比如一个utf8 一个gbk),写死编码格式则会造成冲突,故此改为传入,您需要评估此更改带来的影响,另外我发现了一个独立的FreeRedisClusterCRC16的GetSlot方法的调用,这个我发现是一个单例,全局没有函数调用,所以是否考虑清理这个方法?

2881099 commented 8 months ago

FreeRedisClusterCRC16 这个方法是有个小伙伴 PR 的,他想在外部使用 GetSlot,等有空了再优化这个 API

2881099 commented 8 months ago

v1.2.13 已发布,谢谢反馈