command
module
Version:
v1.0.3
Opens a new window with list of versions in this module.
Published: Jul 9, 2020
License: BSD-2-Clause
Opens a new window with license information.
Imports: 6
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
do-once-while-concurrent
解决并发时对同一资源的重复请求、缓存穿透、数据重复计算,如第三方接口重复请求、redis、数据库重复请求,避免对第三方依赖造成过大压力,以至于服务崩溃,影响到其他服务,同时配合分布式锁,可以解决分布式幂等问题
根据请求标识,对单机同一时刻同一资源的重复请求做限制,只有一个请求等获得锁,其他请求均处于阻塞状态,直到获得执行权限的线程执行结束,释放信号。此时所有请求均能得到数据。

刚发现一位大佬写的,go-singleflight
和我的思路是一样的,用waitgroup实现的通知更好,chan相对麻烦还容易出错
如果没有本地缓存,大佬的更通用,使用更简单;我写的支持更多的自定义操作
Documentation
¶
There is no documentation for this package.
Source Files
¶
Directories
¶
Click to show internal directories.
Click to hide internal directories.