支持缓存+队列,支持驱动:redis、memory

This commit is contained in:
linwenxiang committed 2020-08-10 20:57:17 +08:00
1 parent bdde879238
commit 2b794c03cc
8 files changed
+200 -155

No files matched your search

+31
View File
@@ -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
}