2881099 / csredis

.NET Core or .NET Framework 4.0+ client for Redis and Redis Sentinel (2.8) and Cluster. Includes both synchronous and asynchronous clients.
MIT License
2.01k stars 414 forks source link

可以让pub/sub直接发送或者接受byte[]参数吗? #486

Closed yjqGitHub closed 11 months ago

yjqGitHub commented 12 months ago

您好,我在使用pub/sub过程中发现只能使用string来接收传递消息体,因为一些特殊原因我们需要使用byte[]来发送接收,后续可以支持吗?

2881099 commented 12 months ago

byte[]转成base64再发送

yjqGitHub commented 12 months ago

这样就多了一次序列化和反序列化了,希望能够减少这方面的转换

2881099 commented 12 months ago

我以为是 FreeRedis 的 issues,FreeRedis 支持了这种操作。

2881099 commented 12 months ago

建议切换到 FreeRedis,支持更高版本 redis 功能。

https://github.com/2881099/FreeRedis

支持 STRING、HASH、LIST、SET、ZSET、BITMAP、HyperLogLog、GEO、Stream 以及布隆过滤器等。

参数 默认值 说明
protocol RESP2 若使用 RESP3 协议,你需要 Redis 6.0 环境
user \<empty> Redis 服务端用户名,要求 Redis 6.0 环境
password \<empty> Redis 服务端密码
defaultDatabase 0 Redis 服务端数据库
max poolsize 100 连接池最大连接数
min poolsize 5 连接池最小连接数
idleTimeout 20000 连接池中元素的空闲时间(单位为毫秒 ms),适用于连接到远程服务器
connectTimeout 10000 连接超时,单位为毫秒(ms)
receiveTimeout 10000 接收超时,单位为毫秒(ms)
sendTimeout 10000 发送超时,单位为毫秒(ms)
encoding utf-8 字符串字符集
retry 0 协议发生错误时,重试执行的次数
ssl false 启用加密传输
name \<empty> 连接名,使用 CLIENT LIST 命令查看
prefix \<empty> key 前辍,所有方法都会附带此前辍,cli.Set(prefix + "key", 111);
exitAutoDisposePool true AppDomain.CurrentDomain.ProcessExit/Console.CancelKeyPress 事件自动释放
subscribeReadbytes false Subscribe 读取内容为 byte[]
yjqGitHub commented 11 months ago

freeredis我看了代码它也是只支持发送string和接收string。我想要的是发送是byte[],接收也是byte[]。我看的是给出来的来接口是传递string

2881099 commented 11 months ago

subscribeReadbytes=true

连接串加上这个就可以了

yjqGitHub commented 11 months ago

csredis 后续有计划支持这个吗

yjqGitHub commented 11 months ago

因为线上业务一直在跑,而且业务量较大 不敢将csredis切到freeredis

2881099 commented 11 months ago

可以新增一个组件,只是订阅发布用freeredis