db

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 15 Imported by: 32

Documentation

Index

Constants

View Source
const (
	CtxMongoKey = util.CtxKey("ctxMongoKey")
	HeaderDBKey = "raccMongoDB"
)
View Source
const (
	CoreDB = "core"
	UserDB = "user"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CachePipel added in v1.0.0

type CachePipel interface {
	Get(key string) *redis.StringCmd
	Exec() ([]redis.Cmder, error)
}

type MongoConf

type MongoConf struct {
	Uri       string `yaml:"uri"`
	User      string `yaml:"user"`
	Pass      string `yaml:"pass"`
	DefaultDB string `yaml:"defaul"`
	// contains filtered or unexported fields
}

func (*MongoConf) GetDb added in v1.4.0

func (mc *MongoConf) GetDb() string

func (*MongoConf) GetUri added in v0.12.5

func (mc *MongoConf) GetUri() string

func (*MongoConf) NewMongoDBClient

func (mc *MongoConf) NewMongoDBClient(ctx context.Context, userDB string) (MongoDBClient, error)

func (*MongoConf) SetAuth added in v0.12.2

func (mc *MongoConf) SetAuth(user, pwd string)

type MongoDBClient

type MongoDBClient interface {
	GetCoreDB() *mongo.Database
	GetUserDB() *mongo.Database
	WithSession(f func(sc mongo.SessionContext) error) error
	AbortTransaction(sc mongo.SessionContext) error
	CommitTransaction(sc mongo.SessionContext) error
	Close()
	Ping() error
}

func GetMgoDBClientByCtx added in v1.0.0

func GetMgoDBClientByCtx(ctx context.Context) MongoDBClient

func GetMgoDBClientByGin added in v1.4.0

func GetMgoDBClientByGin(c *gin.Context) MongoDBClient

func GetMgoDBClientByReq added in v1.0.0

func GetMgoDBClientByReq(req *http.Request) MongoDBClient

type MongoDI

type MongoDI interface {
	NewMongoDBClient(ctx context.Context, userDB string) (MongoDBClient, error)
	SetAuth(user, pwd string)
	GetUri() string
	GetDb() string
}

type RedisClient added in v0.8.0

type RedisClient interface {
	Close() error
	Ping() string
	CountKeys() (int, error)
	Get(k string) ([]byte, error)
	Set(k string, v interface{}, exp time.Duration) (string, error)
	Del(k string) (int64, error)
	LPush(k string, v interface{}) (int64, error)
	RPop(k string) ([]byte, error)
	HGet(key string, field string) string
	HSet(key string, values map[string]string) error
	HGetAll(key string) map[string]string
	Exists(key string) bool
	Expired(key string, d time.Duration) (bool, error)
	NewPiple() CachePipel
	Keys(pattern string) ([]string, error)
}

type RedisConf added in v0.8.0

type RedisConf struct {
	Host  string         `yaml:"host"`
	Pwd   string         `yaml:"pass"`
	DbMap map[string]int `yaml:"dbMap"`
}

func (*RedisConf) GetDB added in v1.0.0

func (rc *RedisConf) GetDB(dbname string) int

func (*RedisConf) NewRedisClientDB added in v1.0.0

func (rc *RedisConf) NewRedisClientDB(ctx context.Context, db int) (RedisClient, error)

type RedisDI added in v0.8.0

type RedisDI interface {
	NewRedisClientDB(ctx context.Context, db int) (RedisClient, error)
	GetDB(dbname string) int
}

Jump to

Keyboard shortcuts

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