module
Version:
v0.0.0-...-addcf83
Opens a new window with list of versions in this module.
Published: Nov 14, 2022
License: Apache-2.0
Opens a new window with license information.
README
¶
ARP4G-redis
这是ARP4G的Redis实现。
功能
- 实现基于Redis的持久化
- 实现基于redsync的互斥锁
如何使用
//定义仓库
type OrderRepository interface {
Take(ctx context.Context, id any) (order *Order, found bool)
}
//定义Service
type OrderService struct {
orderRepository OrderRepository
}
//获得redis客户端
redisClient := redis.NewClient(&redis.Options{
Addr: "127.0.0.1:6379",
DB: 0,
})
//生成仓库的redis实现
redisOrderRepo := redisrepo.NewRedisRepository(redisClient, "Order", func() *aggregate.MySession { return &Order{} })
//使用仓库生成Service
orderService := &OrderService{redisOrderRepo}
Directories
¶
Click to show internal directories.
Click to hide internal directories.