支持缓存+队列,支持驱动:redis、memory
This commit is contained in:
1 parent
bdde879238
commit
2b794c03cc
8 files changed
+200
-155
No files matched your search
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"github.com/go-redis/redis/v7"
|
||||
"github.com/matchstalk/redisqueue"
|
||||
"github.com/matchstalk/utils/cache"
|
||||
"time"
|
||||
)
|
||||
|
||||
var RedisAdapter Adapter
|
||||
|
||||
func InitRedis() error {
|
||||
RedisAdapter = &cache.Redis{
|
||||
ConnectOption: &redis.Options{
|
||||
Addr: "127.0.0.1:6379",
|
||||
},
|
||||
ConsumerOptions: &redisqueue.ConsumerOptions{
|
||||
VisibilityTimeout: 60 * time.Second,
|
||||
BlockingTimeout: 5 * time.Second,
|
||||
ReclaimInterval: 1 * time.Second,
|
||||
BufferSize: 100,
|
||||
Concurrency: 10,
|
||||
},
|
||||
ProducerOptions: &redisqueue.ProducerOptions{
|
||||
StreamMaxLength: 100,
|
||||
ApproximateMaxLength: true,
|
||||
},
|
||||
}
|
||||
err := RedisAdapter.Connect()
|
||||
return err
|
||||
}
|
||||
Reference in new issue
Block a user