lxmysql

package module
v0.0.0-...-8ff7ccd Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_EXPIRE   = 300 //默认缓存5分钟
	DEFAULT_MAXCOUNT = 100 //默认最大条数
)

Variables

View Source
var LXMYSQLCACHEDB string //默认缓存数据库

Functions

func CreateTable

func CreateTable(csql string, o orm.Ormer, dbindex string) (err error)

func ExecSql

func ExecSql(config ExecSqlConfig) (err error)

func FindOne

func FindOne(config QueryConfig, result interface{}, args ...interface{}) (err error)

FindOne 查询一条数据

func GenCacheKey

func GenCacheKey(sql string, args []interface{}) string

GenCacheKey 生成缓存名字

func HashCode

func HashCode(sql string, args []interface{}) int

HashCode 计算 SQL 语句的哈希码

func HashCodeOfArg

func HashCodeOfArg(arg interface{}) int

HashCodeOfArg 计算参数的哈希码

func InitMysqls

func InitMysqls(conns []MapMysqlConn, cachedb string) (err error)

InitMysqls 初始化MySQL

func Query

func Query(config QueryConfig, result interface{}, args ...interface{}) (err error)

Query 查询数据

func QueryWithCache

func QueryWithCache(config QueryCacheConfig, result interface{}, args ...interface{}) (err error)

QueryWithCache 查询数据

func ReadFilesql

func ReadFilesql(pth, tbname string) (sql string, err error)

Types

type ExecSqlConfig

type ExecSqlConfig struct {
	Sql        string    //表名
	TableName  string    //表名
	DBIndex    string    //指定数据库
	Orm        orm.Ormer //实例化 ORM
	CreaeSql   string    //创建表的SQL语句
	CreatePath string    //创建表的SQL文件路径
}

type MapMysqlConn

type MapMysqlConn struct {
	Name   string
	SqlCon string
}

type QueryCacheConfig

type QueryCacheConfig struct {
	SQL       string    //sql
	DBIndex   string    //指定数据库
	CacheDB   string    //数据库缓存 Redis数据库索引
	CacheName string    //缓存的名字
	Orm       orm.Ormer //实例化 ORM
	Exexpire  int       //缓存过期时间 -1不使用缓存
}

type QueryConfig

type QueryConfig struct {
	SQL     string    //sql
	DBIndex string    //指定数据库
	Orm     orm.Ormer //实例化 ORM
}

Jump to

Keyboard shortcuts

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