QA:golang redis协议同时写入报错

Q:使用redigo协程并发报错

参考:https://studygolang.com/articles/21266

协程同时send

write tcp 192.168.10.66:7289->192.168.10.66:6379: wsasend: An existing connection was forcibly closed by the remote host.

协程同时DO

short write
write tcp 192.168.10.66:7643->192.168.10.66:6379: use of closed network connection

goredis 说明

Connections support one concurrent caller to the Receive method and one concurrent caller to the Send and Flush methods. No other concurrency is supported including concurrent calls to the Do and Close methods.

A:解决方案

1.使用pool 解决 (推荐)

2.加锁

发布了26 篇原创文章 · 获赞 3 · 访问量 3074
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 游动-白 设计师: 上身试试

分享到微信朋友圈

×

扫一扫,手机浏览