database

package
v2.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 33 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DriverMysql      = "mysql"
	DriverPostgres   = "postgres"
	DriverSqlite     = "sqlite"
	DriverSqlserver  = "sqlserver"
	DriverTidb       = "tidb"
	DriverClickhouse = "clickhouse"
)

Variables

View Source
var Db *gorm.DB

Functions

func ConfigureDBCache added in v2.2.0

func ConfigureDBCache(db *gorm.DB, cacheManager gocache.CacheInterface[any])

func ConfigureMetrics added in v2.2.0

func ConfigureMetrics(db *gorm.DB, dbName string, refreshInterval uint32, labels map[string]string, collectors ...prometheus.MetricsCollector)

func NewDb added in v2.1.8

func NewDb(conf config.Config) (db *gorm.DB)

Types

type CacherAdapter added in v2.2.0

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

func NewCacherAdapter added in v2.2.0

func NewCacherAdapter(cacheManager cache.CacheInterface[any]) *CacherAdapter

func (*CacherAdapter) Delete added in v2.2.0

func (c *CacherAdapter) Delete(tag string, tags ...string) error

func (*CacherAdapter) Get added in v2.2.0

func (c *CacherAdapter) Get(key string) *caches.Query

func (*CacherAdapter) Store added in v2.2.0

func (c *CacherAdapter) Store(key string, val *caches.Query) error

type Marshaler added in v2.2.0

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

Marshaler is the struct that marshal and unmarshal cache values

func NewMarshaler added in v2.2.0

func NewMarshaler(cache cache.CacheInterface[any]) *Marshaler

NewMarshaler creates a new marshaler that marshals/unmarshals cache values

func (*Marshaler) Clear added in v2.2.0

func (c *Marshaler) Clear(ctx context.Context) error

Clear reset all cache data

func (*Marshaler) Delete added in v2.2.0

func (c *Marshaler) Delete(ctx context.Context, key any) error

Delete removes a value from the cache

func (*Marshaler) Get added in v2.2.0

func (c *Marshaler) Get(ctx context.Context, key any, returnObj any) (any, error)

Get obtains a value from cache and unmarshal value with given object

func (*Marshaler) Invalidate added in v2.2.0

func (c *Marshaler) Invalidate(ctx context.Context, options ...store.InvalidateOption) error

Invalidate invalidate cache values using given options

func (*Marshaler) Set added in v2.2.0

func (c *Marshaler) Set(ctx context.Context, key, object any, options ...store.Option) error

Set sets a value in cache by marshaling value

Jump to

Keyboard shortcuts

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