xgodb

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2023 License: BSD-3-Clause-Clear Imports: 6 Imported by: 0

README

xgodb模块说明

此模块为操作数据库的相关模块,依赖 gorm ,使用 MySQL 作为存储数据库

数据库说明

Documentation

Overview

数据库操作相关服务

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cache added in v0.0.15

func Cache() *xgocache.Redis

获取redis读取的Model模型

func CacheExists added in v0.0.15

func CacheExists(key string) bool

判断变量是否存在

keys	待判断的变量名

func CacheGet added in v0.0.15

func CacheGet(key string) (string, error)

获取key的值

key	要获取的key下标

func CacheGetString added in v0.0.15

func CacheGetString(key string) string

获取KEY设置的值

key	要获取的key下标

func CacheGetStruct added in v0.0.15

func CacheGetStruct(key string, val any) error

读取结构体

key	缓存的key名称
val	预期读取的类型【使用json串行化进行反解析】

func CacheKey added in v0.0.15

func CacheKey(args ...any) string

生成CacheKey下标

func CacheSet added in v0.0.15

func CacheSet(key, val string) error

设置Key的值

key	下标
val	值

func CacheSetExt added in v0.0.15

func CacheSetExt(key, val string, t time.Duration) error

设置Key的值

key	下标
val	值
t	延时删除时间

func CacheSetStruct added in v0.0.15

func CacheSetStruct(key string, val any) error

设置结构体

key	缓存的key名称
val	设置的缓存值类型,使用json串行化进行解析存储

func GetBool

func GetBool(name string) bool

获取开关值

func GetFloat

func GetFloat(name string) float64

获取浮点数值

func GetInt

func GetInt(name string) int64

读取配置项的值

func GetSelect

func GetSelect(name string) string

获取select下拉列表

func GetString

func GetString(name string) string

获取string值的配置

func KvId added in v0.0.10

func KvId(val string) uint

KV换取ID信息

value	待查询的信息

func KvValue added in v0.0.10

func KvValue(id uint) string

KV换取VALUE信息

id	待查询的ID值

func Regedit

func Regedit(c Config)

配置信息注册

func SetBool added in v0.0.3

func SetBool(name string, val bool) error

设置bool类型配置

name	配置项的名称
val		配置项的值

func SetFloat added in v0.0.3

func SetFloat(name string, val float64) error

设置float类型配置

name	配置项的名称
val		配置项的值

func SetInt added in v0.0.3

func SetInt(name string, val int64) error

设置int类型配置

name	配置项的名称
val		配置项的值

func SetLongText added in v0.0.3

func SetLongText(name, val string) error

设置longtext类型配置 下拉列表,多项使用,分割key和key_cn使用:分割

name	配置项的名称
val		配置项的值

func SetSelect added in v0.0.3

func SetSelect(name, val string) error

设置select类型配置 下拉列表,多项使用,分割key和key_cn使用:分割

name	配置项的名称
val		配置项的值

func SetString added in v0.0.3

func SetString(name, val string) error

设置string类型配置

name	配置项的名称
val		配置项的值

func SetText added in v0.0.3

func SetText(name, val string) error

设置text类型配置 下拉列表,多项使用,分割key和key_cn使用:分割

name	配置项的名称
val		配置项的值

Types

type Config

type Config struct {
	DB               *gorm.DB
	ConfigTable      string        // 配置表名称
	ConfigUserTable  string        // 用户配置存储表
	KeyValue         string        // key_value表存储名称
	Redis            *redis.Pool   // redis连接配置
	DefaultCacheTime time.Duration // 缓存默认有效期
	RedisPass        string        // redis密码
	RedisSelect      uint8         // redis查询库
}

数据库相关配置

Directories

Path Synopsis
缓存相关
缓存相关
数据库配置的读写支持
数据库配置的读写支持

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳