update: readme.md; feat: add flag
This commit is contained in:
1
pkg/cache/cache.go
vendored
1
pkg/cache/cache.go
vendored
@ -19,6 +19,7 @@ type Cache interface {
|
||||
// SetEx value 会被序列化, 优先使用 MarshalBinary 方法, 没有则执行 json.Marshal
|
||||
SetEx(ctx context.Context, key string, value any, duration time.Duration) error
|
||||
Del(ctx context.Context, keys ...string) error
|
||||
Close() error
|
||||
}
|
||||
|
||||
type Scanner interface {
|
||||
|
5
pkg/cache/cache.lru.go
vendored
5
pkg/cache/cache.lru.go
vendored
@ -134,6 +134,11 @@ func (l *_lru) Del(ctx context.Context, keys ...string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (l *_lru) Close() error {
|
||||
l.client = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func newLRUCache() (Cache, error) {
|
||||
client := expirable.NewLRU[string, *_lru_value](1024*1024, nil, 0)
|
||||
|
||||
|
6
pkg/cache/cache.memory.go
vendored
6
pkg/cache/cache.memory.go
vendored
@ -103,3 +103,9 @@ func (m *_mem) Del(ctx context.Context, keys ...string) error {
|
||||
m.client.Delete(keys...)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *_mem) Close() error {
|
||||
m.client = nil
|
||||
|
||||
return nil
|
||||
}
|
||||
|
4
pkg/cache/cache.redis.go
vendored
4
pkg/cache/cache.redis.go
vendored
@ -104,3 +104,7 @@ func (r *_redis) SetEx(ctx context.Context, key string, value any, duration time
|
||||
func (r *_redis) Del(ctx context.Context, keys ...string) error {
|
||||
return r.client.Del(ctx, keys...).Err()
|
||||
}
|
||||
|
||||
func (r *_redis) Close() error {
|
||||
return r.client.Close()
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type Upp interface {
|
||||
Debug() bool
|
||||
UseCtx() context.Context
|
||||
UseDB(ctx ...context.Context) *gorm.DB
|
||||
UseCache() cache.Cache
|
||||
|
Reference in New Issue
Block a user