redisext

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

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

func (c *RedisExt) AddPrefix(key string) string

AddPrefix add prefix to a key

Example
package main

import (
	"fmt"

	"github.com/apocelipes/gobay"
	"github.com/apocelipes/gobay/extensions/redisext"
)

func main() {
	redis := &redisext.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) Application

func (c *RedisExt) Application() *gobay.Application

Application

func (*RedisExt) CheckHealth

func (c *RedisExt) CheckHealth(ctx context.Context) error
Example
package main

import (
	"context"
	"fmt"

	"github.com/apocelipes/gobay"
	"github.com/apocelipes/gobay/extensions/redisext"
)

func main() {
	redis := &redisext.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>

func (*RedisExt) Client

func (c *RedisExt) Client(ctx context.Context) *redis.Client

func (*RedisExt) Close

func (c *RedisExt) Close() error

Close close redis client

func (*RedisExt) Init

func (c *RedisExt) Init(app *gobay.Application) error

Init

func (*RedisExt) Object

func (c *RedisExt) Object() interface{}

Object return redis client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL