Documentation
¶
Index ¶
- Variables
- func IsNotFound(err error) bool
- func IsNotFoundAny(err error) bool
- func IsRedisNil(err error) bool
- func NormalizeErr(err error) error
- func SetRedisSessionResolver(fn func() RedisSession)
- type C
- type Options
- type RedisContext
- func (r *RedisContext) Del(ctx context.Context, keys ...string) error
- func (r *RedisContext) Exists(ctx context.Context, key string) (bool, error)
- func (r *RedisContext) Get(ctx context.Context, key string) (string, error)
- func (r *RedisContext) Publish(ctx context.Context, channel string, message any) error
- func (r *RedisContext) Set(ctx context.Context, key string, value any, ttl time.Duration) error
- type RedisOptions
- type RedisSession
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errNotFound
ErrNotFound is returned by framework APIs after NormalizeErr (not redis.Nil).
Functions ¶
func IsNotFound ¶ added in v1.22.7
IsNotFound reports normalized not-found errors from RedisContext / cache.C.
func IsNotFoundAny ¶ added in v1.22.8
IsNotFoundAny reports not-found when err source is unknown or mixed.
func IsRedisNil ¶ added in v1.22.8
IsRedisNil reports raw go-redis missing-key errors. Use for direct go-redis calls only.
func NormalizeErr ¶ added in v1.22.7
NormalizeErr maps redis driver errors to cache-level errors.
func SetRedisSessionResolver ¶ added in v1.22.7
func SetRedisSessionResolver(fn func() RedisSession)
SetRedisSessionResolver installs the global session resolver (used by factory).
Types ¶
type C ¶
type C interface {
Get(key string, value interface{}) (err error)
GetSkipLocal(key string, value interface{}) (err error)
GetProxy() *cache.Cache
Exists(key string) bool
Set(key string, value interface{}) (err error)
SetTTL(key string, value interface{}, ttl time.Duration) (err error)
Del(key string) error
}
type RedisContext ¶ added in v1.22.7
type RedisContext struct {
// contains filtered or unexported fields
}
RedisContext is the facade for RedisSession, similar to persistence.OrmContext.
func NewRedis ¶ added in v1.22.7
func NewRedis() *RedisContext
func WrapRedisSession ¶ added in v1.22.7
func WrapRedisSession(s RedisSession) *RedisContext
func (*RedisContext) Del ¶ added in v1.22.7
func (r *RedisContext) Del(ctx context.Context, keys ...string) error
type RedisOptions ¶
type RedisSession ¶ added in v1.22.7
type RedisSession interface {
Get(ctx context.Context, key string) (string, error)
Set(ctx context.Context, key string, value any, ttl time.Duration) error
Del(ctx context.Context, keys ...string) error
Exists(ctx context.Context, key string) (bool, error)
Publish(ctx context.Context, channel string, message any) error
}
RedisSession is the low-level Redis command surface (KV, pub/sub).
func NewRedisSession ¶ added in v1.22.7
func NewRedisSession(c *redis.Client) RedisSession
NewRedisSession wraps a go-redis client; client stays inside cache package.