Documentation ¶
Index ¶
- type RedisExt
- func (c *RedisExt) AddPrefix(key string) string
- func (c *RedisExt) Application() *gobay.Application
- func (c *RedisExt) CheckHealth(ctx context.Context) error
- func (c *RedisExt) Client() *redis.Client
- func (c *RedisExt) Close() error
- func (c *RedisExt) EvalLua(ctx context.Context, script string, keys []string, args ...any) (any, error)
- func (c *RedisExt) Init(app *gobay.Application) error
- func (c *RedisExt) Object() interface{}
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedisExt ¶
type RedisExt struct { NS string // contains filtered or unexported fields }
RedisExt redis扩展,处理client的初始化工作
func (*RedisExt) AddPrefix ¶
AddPrefix add prefix to a key
Example ¶
package main import ( "fmt" "github.com/shanbay/gobay" redisv9ext "github.com/shanbay/gobay/extensions/redisext/v9" ) func main() { redis := &redisv9ext.RedisExt{NS: "redis_"} exts := map[gobay.Key]gobay.Extension{ "redis": redis, } if _, err := gobay.CreateApp("../../../testdata/", "testing", exts); err != nil { fmt.Println(err) return } prefixKey := redis.AddPrefix("testRawKey") fmt.Println(prefixKey) }
Output: github-redis.testRawKey
func (*RedisExt) CheckHealth ¶
Example ¶
package main import ( "context" "fmt" "github.com/shanbay/gobay" redisv9ext "github.com/shanbay/gobay/extensions/redisext/v9" ) func main() { redis := &redisv9ext.RedisExt{NS: "redis_"} exts := map[gobay.Key]gobay.Extension{ "redis": redis, } if _, err := gobay.CreateApp("../../../testdata/", "testing", exts); err != nil { fmt.Println(err) return } err := redis.CheckHealth(context.Background()) fmt.Println(err) }
Output: <nil>
Click to show internal directories.
Click to hide internal directories.