gorm

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Created by guoxin in 2023/12/12 16:44

Created by guoxin in 2023/12/12 17:59

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRedisClient

func GetRedisClient(conf zeroredis.RedisConf) (*redis.Client, error)

func NewCacheFromClusterConf

func NewCacheFromClusterConf(conf kv.KvConf) (*cache.Gorm2Cache, error)

func NewCacheFromRedisConf

func NewCacheFromRedisConf(conf CacheConf, getCli func(zeroredis.RedisConf) (*redis.Client, error)) (*cache.Gorm2Cache, error)

func NewGorm

func NewGorm(conf DBConf, plugins ...gorm.Plugin) (*gorm.DB, error)

NewGorm @Description: 创建DB @param conf @param plugins @return *gorm.DB @return error

func NewGormCache

func NewGormCache(conf DBConf, getCli func(zeroredis.RedisConf) (*redis.Client, error)) (*gorm.DB, error)

NewGormCache @Description: NewGormCache getCli 默认使用 GetRedisClient 方法 @param conf @param getCli @return *gorm.DB @return error

func NewGormFromDialector

func NewGormFromDialector(dialector gorm.Dialector, plugins ...gorm.Plugin) (*gorm.DB, error)

NewGormFromDialector @Description: @param dialector @param plugins @return *gorm.DB @return error

Types

type CacheConf

type CacheConf struct {
	Redis    zeroredis.RedisConf `json:","`
	Tables   []string            `json:",optional"`
	CacheTTL int64               `json:",optional"`
	// config.CacheLevelOff
	// config.CacheLevelOnlyPrimary
	// config.CacheLevelOnlySearch
	// config.CacheLevelAll
	Level int `json:",optional"`
	// config.CacheStorageMemory
	// config.CacheStorageRedis
	Storage int `json:",optional"`
}

type DBConf

type DBConf struct {
	DataSource string `json:",optional"`
	// support type, mysql kingbase postgresql pgsql
	Type  string    `json:",optional"`
	Cache CacheConf `json:",optional"`
}

Directories

Path Synopsis
Created by guoxin in 2024/3/1 14:40
Created by guoxin in 2024/3/1 14:40

Jump to

Keyboard shortcuts

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