Compare commits
No commits in common. "main" and "v0.0.11" have entirely different histories.
|
@ -57,16 +57,9 @@ func WithAllow(paths ...string) Option {
|
|||
}
|
||||
}
|
||||
|
||||
func WithClaims(claims any) Option {
|
||||
func WithClaims(claims reflect.Type) Option {
|
||||
return func(o *options) {
|
||||
if tv, ok := claims.(reflect.Type); ok {
|
||||
o.claims = tv
|
||||
} else {
|
||||
o.claims = reflect.TypeOf(claims)
|
||||
if o.claims.Kind() == reflect.Ptr {
|
||||
o.claims = o.claims.Elem()
|
||||
}
|
||||
}
|
||||
o.claims = claims
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"git.nobla.cn/golang/aeus"
|
||||
)
|
||||
|
||||
type redisCache struct {
|
||||
|
@ -59,12 +57,7 @@ func (c *redisCache) String() string {
|
|||
}
|
||||
|
||||
func NewCache(opts ...Option) *redisCache {
|
||||
cache := &redisCache{
|
||||
return &redisCache{
|
||||
opts: newOptions(opts...),
|
||||
}
|
||||
app := aeus.FromContext(cache.opts.context)
|
||||
if app != nil {
|
||||
cache.opts.prefix = app.Name() + ":" + cache.opts.prefix
|
||||
}
|
||||
return cache
|
||||
}
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
package redis
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
type (
|
||||
options struct {
|
||||
context context.Context
|
||||
client *redis.Client
|
||||
prefix string
|
||||
client *redis.Client
|
||||
prefix string
|
||||
}
|
||||
|
||||
Option func(*options)
|
||||
|
@ -22,12 +19,6 @@ func WithClient(client *redis.Client) Option {
|
|||
}
|
||||
}
|
||||
|
||||
func WithContext(ctx context.Context) Option {
|
||||
return func(o *options) {
|
||||
o.context = ctx
|
||||
}
|
||||
}
|
||||
|
||||
func WithPrefix(prefix string) Option {
|
||||
return func(o *options) {
|
||||
o.prefix = prefix
|
||||
|
|
Loading…
Reference in New Issue