cache

package
v0.3.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DialectRedis        = "redis"
	DialectRedisCluster = "rediss"
)

Variables

This section is empty.

Functions

func GetDriverAndName

func GetDriverAndName(cacheSourceAddress string) (csd, csn string, err error)

func IsConnected

func IsConnected(ctx context.Context, drv Driver) error

func NewStatsCollectorWith

func NewStatsCollectorWith(drv Driver) prometheus.Collector

func Wait

func Wait(ctx context.Context, drv Driver) (err error)

Types

type Driver

type Driver interface {
	// SetMaxIdleConns sets the maximum number of connections in the idle connection pool.
	SetMaxIdleConns(n int)

	// SetMaxOpenConns sets the maximum number of open connections to the database.
	SetMaxOpenConns(n int)

	// SetConnMaxLifetime sets the maximum amount of time a connection may be reused.
	SetConnMaxLifetime(d time.Duration)

	// SetConnMaxIdleTime sets the maximum amount of time a connection may be idle.
	SetConnMaxIdleTime(d time.Duration)

	// PingContext verifies a connection to the database is still alive,
	// establishing a connection if necessary.
	PingContext(context.Context) error

	// Underlay returns the underlay client dialect and client.
	Underlay(context.Context) (string, any, error)

	// Stats returns driver statistics.
	Stats() DriverStats
}

func LoadDriver

func LoadDriver(cacheSourceAddress string) (drvDialect string, drv Driver, err error)

type DriverStats

type DriverStats struct {
	MaxOpenConnections int64 // Maximum number of open connections.
	IdleConnections    int64 // The number of idle connections.

	NewOpenCount int64 // The total number of free connection was not found in the pool.
	TimeoutCount int64 // The total number of timeout getting a connection from the pool.
	ClosedCount  int64 // The total number of connections closed in the pool.
}

Jump to

Keyboard shortcuts

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