database

package
v1.1.58 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package database provides database client initialization.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCacheNotFound No hit cache
	ErrCacheNotFound = goredis.ErrRedisNotFound
)
View Source
var (
	ErrRecordNotFound = sgorm.ErrRecordNotFound
)

Functions

func CloseDB

func CloseDB() error

CloseDB close db

func CloseRedis

func CloseRedis() error

CloseRedis close redis

func GetDB

func GetDB() *sgorm.DB

GetDB get db

func GetRedisCli

func GetRedisCli() *goredis.Client

GetRedisCli get redis client

func GetSnowId

func GetSnowId() snowflake.ID

func GetSnowNode

func GetSnowNode() *snowflake.Node

GetSnowNode get db

func InitCache

func InitCache(cType string)

InitCache initial cache

func InitDB

func InitDB()

InitDB connect database

func InitMysql

func InitMysql() *sgorm.DB

InitMysql connect mysql

func InitPostgresql

func InitPostgresql() *sgorm.DB

InitPostgresql connect postgresql

func InitRedis

func InitRedis()

InitRedis connect redis

func InitSnowNode

func InitSnowNode()

InitSnowNode connect redis

func InitSqlite

func InitSqlite() *sgorm.DB

InitSqlite connect sqlite

Types

type CacheType

type CacheType struct {
	CType string          // cache type  memory or redis
	Rdb   *goredis.Client // if CType=redis, Rdb cannot be empty
}

CacheType cache type

func GetCacheType

func GetCacheType() *CacheType

GetCacheType get cacheType

Jump to

Keyboard shortcuts

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