db

package
v0.0.0-...-859a9ad Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseMysqlDB

func CloseMysqlDB()

CloseMysqlDB close mysql connection.

func CloseRedis

func CloseRedis()

CloseRedis close redis client instance.

func GetMysqlDB

func GetMysqlDB() *gorm.DB

GetMysqlDB get mysql connection.

func InitInfluxDB

func InitInfluxDB()

InitInfluxDB init influxdb connection.

func InitMysqlDB

func InitMysqlDB()

InitMysqlDB init mysql connection.

func InitRedisDB

func InitRedisDB()

InitRedisDB init redis client.

Types

type InfluxDB

type InfluxDB struct {
	// for query
	Org    string
	Bucket string
	// contains filtered or unexported fields
}

InfluxDB influxdb client.

func GetInfluxDBClient

func GetInfluxDBClient() *InfluxDB

GetInfluxDBClient get influxdb client.

func (*InfluxDB) BuildQuery

func (i *InfluxDB) BuildQuery(bucket, measurement, field, aggPeriod, aggFn, actionStr, uuid string,
	startTime, endTime int64,
) string

BuildQuery build query string.

func (*InfluxDB) BuildQueryWithCount

func (i *InfluxDB) BuildQueryWithCount(bucket, period, measurement, uuid string) string

BuildQueryWithCount build query string with count.

func (*InfluxDB) BuildQueryWithPage

func (i *InfluxDB) BuildQueryWithPage(bucket, period, measurement, uuid string,
	pagesize, page int,
) string

BuildQueryWithPage build query string with page.

func (*InfluxDB) GetQueryAPI

func (i *InfluxDB) GetQueryAPI() api.QueryAPI

GetQueryAPI get query api.

func (*InfluxDB) GetWriteAPI

func (i *InfluxDB) GetWriteAPI() api.WriteAPIBlocking

GetWriteAPI get write api.

type RealRedisClient

type RealRedisClient struct {
	// contains filtered or unexported fields
}

RealRedisClient implemented the RedisClient interface and used a real Redis client.

func (*RealRedisClient) Close

func (r *RealRedisClient) Close() error

Close close redis client.

func (*RealRedisClient) Del

func (r *RealRedisClient) Del(ctx context.Context, keys ...string) *redis.IntCmd

Del delete key.

func (*RealRedisClient) Exists

func (r *RealRedisClient) Exists(ctx context.Context, keys ...string) *redis.IntCmd

Exists check some keys are exis.

func (*RealRedisClient) Expire

func (r *RealRedisClient) Expire(ctx context.Context, key string, ttl time.Duration) *redis.BoolCmd

Expire expire key.

func (*RealRedisClient) ExpireAt

func (r *RealRedisClient) ExpireAt(ctx context.Context, key string, ttl time.Time) *redis.BoolCmd

ExpireAt expire key at time.

func (*RealRedisClient) Get

func (r *RealRedisClient) Get(ctx context.Context, key string) *redis.StringCmd

Get get value.

func (*RealRedisClient) HDel

func (r *RealRedisClient) HDel(ctx context.Context, key string, fields ...string) *redis.IntCmd

HDel hdel.

func (*RealRedisClient) HExists

func (r *RealRedisClient) HExists(ctx context.Context, key, field string) *redis.BoolCmd

HExists hexists.

func (*RealRedisClient) HGet

func (r *RealRedisClient) HGet(ctx context.Context, key, field string) *redis.StringCmd

HGet hget.

func (*RealRedisClient) HGetAll

func (r *RealRedisClient) HGetAll(ctx context.Context, key string) *redis.StringStringMapCmd

HGetAll hgetall.

func (*RealRedisClient) HIncrBy

func (r *RealRedisClient) HIncrBy(ctx context.Context, key, field string, incr int64) *redis.IntCmd

HIncrBy hincrby.

func (*RealRedisClient) HKeys

func (r *RealRedisClient) HKeys(ctx context.Context, key string) *redis.StringSliceCmd

HKeys hkeys.

func (*RealRedisClient) HLen

func (r *RealRedisClient) HLen(ctx context.Context, key string) *redis.IntCmd

HLen hlen.

func (*RealRedisClient) HMGet

func (r *RealRedisClient) HMGet(ctx context.Context, key string, fields ...string) *redis.SliceCmd

HMGet hmget.

func (*RealRedisClient) HMSet

func (r *RealRedisClient) HMSet(ctx context.Context, key string, values ...interface{}) *redis.BoolCmd

HMSet hmset.

func (*RealRedisClient) HSet

func (r *RealRedisClient) HSet(ctx context.Context, key string, values ...interface{}) *redis.IntCmd

HSet hset.

func (*RealRedisClient) Incr

func (r *RealRedisClient) Incr(ctx context.Context, key string) *redis.IntCmd

Incr incr key.

func (*RealRedisClient) LIndex

func (r *RealRedisClient) LIndex(ctx context.Context, key string, index int64) *redis.StringCmd

LIndex get index value.

func (*RealRedisClient) LLen

func (r *RealRedisClient) LLen(ctx context.Context, key string) *redis.IntCmd

LLen get list length.

func (*RealRedisClient) LPop

func (r *RealRedisClient) LPop(ctx context.Context, key string) *redis.StringCmd

LPop left pop value from list.

func (*RealRedisClient) LPush

func (r *RealRedisClient) LPush(ctx context.Context, key string, values ...interface{}) *redis.IntCmd

LPush left push value to list.

func (*RealRedisClient) LRange

func (r *RealRedisClient) LRange(ctx context.Context, key string, start, stop int64) *redis.StringSliceCmd

LRange get list value from start to stop.

func (*RealRedisClient) LRem

func (r *RealRedisClient) LRem(ctx context.Context, key string, count int64, value interface{}) *redis.IntCmd

LRem remove count value from list.

func (*RealRedisClient) LTrim

func (r *RealRedisClient) LTrim(ctx context.Context, key string, start, stop int64) *redis.StatusCmd

LTrim trim list from start to stop.

func (*RealRedisClient) Pipeline

func (r *RealRedisClient) Pipeline() redis.Pipeliner

Pipeline pipline.

func (*RealRedisClient) Pipelined

func (r *RealRedisClient) Pipelined(ctx context.Context, fn func(redis.Pipeliner) error) ([]redis.Cmder, error)

Pipelined pipelined.

func (*RealRedisClient) RPop

func (r *RealRedisClient) RPop(ctx context.Context, key string) *redis.StringCmd

RPop right pop value from list.

func (*RealRedisClient) RPush

func (r *RealRedisClient) RPush(ctx context.Context, key string, values ...interface{}) *redis.IntCmd

RPush right push value to list.

func (*RealRedisClient) Set

func (r *RealRedisClient) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd

Set set key value pair to redis.

func (*RealRedisClient) TTL

func (r *RealRedisClient) TTL(ctx context.Context, key string) *redis.DurationCmd

TTL get ttl of key.

func (*RealRedisClient) TxPipeline

func (r *RealRedisClient) TxPipeline() redis.Pipeliner

TxPipeline tx pipeline.

func (*RealRedisClient) TxPipelined

func (r *RealRedisClient) TxPipelined(ctx context.Context, fn func(redis.Pipeliner) error) ([]redis.Cmder, error)

TxPipelined tx pipelined.

func (*RealRedisClient) Watch

func (r *RealRedisClient) Watch(ctx context.Context, fn func(*redis.Tx) error, keys ...string) error

Watch watch.

func (*RealRedisClient) ZAdd

func (r *RealRedisClient) ZAdd(ctx context.Context, key string, members ...*redis.Z) *redis.IntCmd

ZAdd zset add.

func (*RealRedisClient) ZRange

func (r *RealRedisClient) ZRange(ctx context.Context, key string, start, stop int64) *redis.StringSliceCmd

ZRange zset range.

func (*RealRedisClient) ZRem

func (r *RealRedisClient) ZRem(ctx context.Context, key string, members ...interface{}) *redis.IntCmd

ZRem zset remove.

type RedisClient

type RedisClient interface {
	// default
	Get(ctx context.Context, key string) *redis.StringCmd
	Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	TTL(ctx context.Context, key string) *redis.DurationCmd
	Expire(ctx context.Context, key string, ttl time.Duration) *redis.BoolCmd
	ExpireAt(ctx context.Context, key string, ttl time.Time) *redis.BoolCmd
	Exists(ctx context.Context, keys ...string) *redis.IntCmd
	Del(ctx context.Context, keys ...string) *redis.IntCmd
	Incr(ctx context.Context, key string) *redis.IntCmd
	Close() error

	// List
	LPush(ctx context.Context, key string, values ...interface{}) *redis.IntCmd
	RPush(ctx context.Context, key string, values ...interface{}) *redis.IntCmd
	LPop(ctx context.Context, key string) *redis.StringCmd
	RPop(ctx context.Context, key string) *redis.StringCmd
	LRange(ctx context.Context, key string, start, stop int64) *redis.StringSliceCmd
	LRem(ctx context.Context, key string, count int64, value interface{}) *redis.IntCmd
	LTrim(ctx context.Context, key string, start, stop int64) *redis.StatusCmd
	LLen(ctx context.Context, key string) *redis.IntCmd
	LIndex(ctx context.Context, key string, index int64) *redis.StringCmd

	// tx
	Pipelined(ctx context.Context, fn func(redis.Pipeliner) error) ([]redis.Cmder, error)
	Pipeline() redis.Pipeliner
	TxPipelined(ctx context.Context, fn func(redis.Pipeliner) error) ([]redis.Cmder, error)
	TxPipeline() redis.Pipeliner

	// ZSet
	ZAdd(ctx context.Context, key string, members ...*redis.Z) *redis.IntCmd
	ZRem(ctx context.Context, key string, members ...interface{}) *redis.IntCmd
	ZRange(ctx context.Context, key string, start, stop int64) *redis.StringSliceCmd

	// map
	HSet(ctx context.Context, key string, values ...interface{}) *redis.IntCmd
	HGet(ctx context.Context, key, field string) *redis.StringCmd
	HGetAll(ctx context.Context, key string) *redis.StringStringMapCmd
	HDel(ctx context.Context, key string, fields ...string) *redis.IntCmd
	HExists(ctx context.Context, key, field string) *redis.BoolCmd
	HIncrBy(ctx context.Context, key, field string, incr int64) *redis.IntCmd
	HKeys(ctx context.Context, key string) *redis.StringSliceCmd
	HLen(ctx context.Context, key string) *redis.IntCmd
	HMGet(ctx context.Context, key string, fields ...string) *redis.SliceCmd
	HMSet(ctx context.Context, key string, values ...interface{}) *redis.BoolCmd

	Watch(ctx context.Context, fn func(*redis.Tx) error, keys ...string) error
}

RedisClient the interface defines the methods for interacting with Redis clients.

func GetRedis

func GetRedis() RedisClient

GetRedis get redis client instance.

Jump to

Keyboard shortcuts

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