initialize

package
v0.0.0-...-fae7c5d Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB
View Source
var LOG_DB *gorm.DB
View Source
var RDB redis.Cmdable
View Source
var RedisEnabled = true
View Source
var SQLiteBusyTimeout = env.Int("SQLITE_BUSY_TIMEOUT", 3000)
View Source
var SQLitePath = "one-api.db"
View Source
var UsingMySQL = false
View Source
var UsingPostgreSQL = false
View Source
var UsingSQLite = false

Functions

func CloseDB

func CloseDB() error

func CreateRootAccountIfNeed

func CreateRootAccountIfNeed() error

func InitDB

func InitDB()

func InitLogDB

func InitLogDB()

func InitRedisClient

func InitRedisClient() (err error)

InitRedisClient This function is called after init()

func ParseRedisOption

func ParseRedisOption() *redis.Options

func RedisDecrease

func RedisDecrease(key string, value int64) error

func RedisDel

func RedisDel(key string) error

func RedisGet

func RedisGet(key string) (string, error)

func RedisSet

func RedisSet(key string, value string, expiration time.Duration) error

Types

type Redis

type Redis struct {
	Name         string   `mapstructure:"name" json:"name" yaml:"name"`                         // 代表当前实例的名字
	Addr         string   `mapstructure:"addr" json:"addr" yaml:"addr"`                         // 服务器地址:端口
	Password     string   `mapstructure:"password" json:"password" yaml:"password"`             // 密码
	DB           int      `mapstructure:"db" json:"db" yaml:"db"`                               // 单实例模式下redis的哪个数据库
	UseCluster   bool     `mapstructure:"useCluster" json:"useCluster" yaml:"useCluster"`       // 是否使用集群模式
	ClusterAddrs []string `mapstructure:"clusterAddrs" json:"clusterAddrs" yaml:"clusterAddrs"` // 集群模式下的节点地址列表
}

Jump to

Keyboard shortcuts

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