Documentation
¶
Index ¶
- Constants
- func BaseHashArrayCache(cli *GsRedis, key string, queryFunc func() (map[string]map[string]any, error), ...) (map[string]map[string]any, error)
- func BaseHashCache(cli *GsRedis, key string, queryFunc func() (map[string]string, error), ...) (map[string]string, error)
- func BaseString2Cache(cli *GsRedis, key string, queryFunc func() (map[string]any, error), ...) (string, error)
- func BaseStringCache(cli *GsRedis, key string, queryFunc func() (map[string]any, error), ...) (map[string]any, error)
- func RedisGetKey(client *GsRedis, key string) string
- func RedisGetKeyE(client *GsRedis, key string) (string, error)
- func RedisGetStringCall(client *GsRedis, key string, call func() string, expire time.Duration) string
- func RedisGetStringCallE(client *GsRedis, key string, call func() string, expire time.Duration) (string, error)
- func RedisHash(client *GsRedis, key, subKey string, call func() map[string]string, ...) string
- func RedisHashAll(client *GsRedis, key string, call func() map[string]string, ...) map[string]string
- func RedisHashAllE(client *GsRedis, key string, call func() map[string]string, ...) (map[string]string, error)
- func RedisHashE(client *GsRedis, key, subKey string, call func() map[string]string, ...) (string, error)
- func RedisKeyExist(client *GsRedis, key string) (bool, error)
- func RedisSetExpire(client *GsRedis, key string, expire time.Duration) error
- func RedisSetNx(client *GsRedis, key, value string, expire time.Duration) bool
- func RedisSetNxE(client *GsRedis, key, value string, expire time.Duration) (bool, error)
- type GsMysql
- func (h *GsMysql) CreateConn() error
- func (h *GsMysql) ExecBySql(sqlStr string, params ...interface{}) *SqlQuick
- func (h *GsMysql) GetTx() (*sql.Tx, error)
- func (h *GsMysql) InsertBySql(sqlStr string, params ...interface{}) *SqlQuick
- func (h *GsMysql) OpenDebug()
- func (h *GsMysql) QueryBySql(sqlStr string, params ...interface{}) *SqlQuick
- func (h *GsMysql) QuickCreate(tableName string, params map[string]interface{}) *SqlQuick
- func (h *GsMysql) QuickDelete(tableName string, where map[string]interface{}) *SqlQuick
- func (h *GsMysql) QuickQuery(tableName, fields string, where map[string]interface{}) *SqlQuick
- func (h *GsMysql) QuickUpdate(tableName string, where map[string]interface{}, update map[string]interface{}) *SqlQuick
- func (h *GsMysql) SetGsLog(gsLog *gstool.GsSlog)
- func (h *GsMysql) SetOpenFunc(openFunc func(db *sql.DB))
- func (h *GsMysql) TableDetail(tableName string) *SqlQuick
- type GsPgsql
- func (h *GsPgsql) CreateConn() error
- func (h *GsPgsql) ExecBySql(sqlStr string, params ...interface{}) *SqlQuick
- func (h *GsPgsql) GetTx() (*sql.Tx, error)
- func (h *GsPgsql) InsertBySql(sqlStr string, params ...interface{}) *SqlQuick
- func (h *GsPgsql) OpenDebug()
- func (h *GsPgsql) QueryBySql(sqlStr string, params ...interface{}) *SqlQuick
- func (h *GsPgsql) QuickCreate(tableName string, params map[string]interface{}) *SqlQuick
- func (h *GsPgsql) QuickDelete(tableName string, where map[string]interface{}) *SqlQuick
- func (h *GsPgsql) QuickQuery(tableName, fields string, where map[string]interface{}) *SqlQuick
- func (h *GsPgsql) QuickUpdate(tableName string, where map[string]interface{}, update map[string]interface{}) *SqlQuick
- func (h *GsPgsql) SetGsLog(gsLog *gstool.GsSlog)
- func (h *GsPgsql) SetOpenFunc(openFunc func(db *sql.DB))
- func (h *GsPgsql) TableDetail(tableName string) *SqlQuick
- type GsRedis
- type GsSqlite
- func (h *GsSqlite) CreateConn() error
- func (h *GsSqlite) ExecBySql(sqlStr string, params ...interface{}) *SqlQuick
- func (h *GsSqlite) GetTx() (*sql.Tx, error)
- func (h *GsSqlite) InsertBySql(sqlStr string, params ...interface{}) *SqlQuick
- func (h *GsSqlite) OpenDebug()
- func (h *GsSqlite) QueryBySql(sqlStr string, params ...interface{}) *SqlQuick
- func (h *GsSqlite) QuickCreate(tableName string, params map[string]interface{}) *SqlQuick
- func (h *GsSqlite) QuickDelete(tableName string, where map[string]interface{}) *SqlQuick
- func (h *GsSqlite) QuickQuery(tableName, fields string, where map[string]interface{}) *SqlQuick
- func (h *GsSqlite) QuickUpdate(tableName string, where map[string]interface{}, update map[string]interface{}) *SqlQuick
- func (h *GsSqlite) SetGsLog(gsLog *gstool.GsSlog)
- func (h *GsSqlite) TableDetail(tableName string) *SqlQuick
- type MysqlConfig
- type PgsqlConfig
- type RedisConfig
- type SqlFormat
- func (h *SqlFormat) FormatInsert(tableName string, insert map[string]any) (string, string, []any, error)
- func (h *SqlFormat) FormatQuery(tableName string, where map[string]any, valueList *[]any) (string, error)
- func (h *SqlFormat) FormatUpdate(tableName string, update map[string]any, valueList *[]any) (string, error)
- type SqlQuick
- func (h *SqlQuick) All(txs ...*sql.Tx) ([]map[string]any, error)
- func (h *SqlQuick) Debug() *SqlQuick
- func (h *SqlQuick) Debugf(msg string, params ...interface{})
- func (h *SqlQuick) Errof(msg string, params ...interface{})
- func (h *SqlQuick) Exec(txs ...*sql.Tx) (int64, error)
- func (h *SqlQuick) ExecBySql(sqlStr string, params ...interface{}) *SqlQuick
- func (h *SqlQuick) GetSql() string
- func (h *SqlQuick) InsertBySql(sqlStr string, params ...interface{}) *SqlQuick
- func (h *SqlQuick) Limit(limit int) *SqlQuick
- func (h *SqlQuick) OffsetLimit(offset, limit int) *SqlQuick
- func (h *SqlQuick) One(txs ...*sql.Tx) (map[string]any, error)
- func (h *SqlQuick) Order(orderSql string) *SqlQuick
- func (h *SqlQuick) QueryBySql(sqlStr string, params ...interface{}) *SqlQuick
- func (h *SqlQuick) QuickCreate(tableName string, params map[string]interface{}, primaryKey ...string) *SqlQuick
- func (h *SqlQuick) QuickDelete(tableName string, where map[string]interface{}) *SqlQuick
- func (h *SqlQuick) QuickQuery(tableName, fields string, where map[string]interface{}) *SqlQuick
- func (h *SqlQuick) QuickUpdate(tableName string, where map[string]interface{}, update map[string]interface{}) *SqlQuick
- func (h *SqlQuick) Select() (any, error)
- func (h *SqlQuick) Selects() ([]any, error)
- func (h *SqlQuick) TableColumnsMap(columnList []map[string]any) (map[string]string, error)
- func (h *SqlQuick) TableDetail(tableName string) ([]map[string]any, error)
Constants ¶
const ( Query = iota Insert Update Delete Exec //仅返回受影响行数 如果是插入 需要使用Insert )
const DbTypeMysql = `mysql`
const DbTypePgsql = `pgsql`
const DbTypeSqlite = `sqlite`
const RedisKeyHash = `hash`
const RedisKeyList = `list`
const RedisKeySet = `set`
const RedisKeyString = `string`
const RedisKeyZSet = `zset`
Variables ¶
This section is empty.
Functions ¶
func BaseHashArrayCache ¶
func BaseHashArrayCache(cli *GsRedis, key string, queryFunc func() (map[string]map[string]any, error), expired time.Duration) (map[string]map[string]any, error)
BaseHashArrayCache map[string]map[string]any -> hash[string]string init 将一个双层map存为 hash
func BaseHashCache ¶
func BaseHashCache(cli *GsRedis, key string, queryFunc func() (map[string]string, error), expired time.Duration) (map[string]string, error)
BaseHashCache map[string]string -> hash[string]string 将单层map存入hash
func BaseString2Cache ¶
func BaseString2Cache(cli *GsRedis, key string, queryFunc func() (map[string]any, error), expired time.Duration) (string, error)
BaseString2Cache map[string]any -> string 将一个map[string]any 存为 string 最后返回string
func BaseStringCache ¶
func BaseStringCache(cli *GsRedis, key string, queryFunc func() (map[string]any, error), expired time.Duration) (map[string]any, error)
BaseStringCache map[string]any -> string 将一个map[string]any 存为 string
func RedisGetKey ¶
RedisGetKey 获取key的值 @deprecated 不再使用
func RedisGetKeyE ¶
RedisGetKeyE 获取key的值 @deprecated 不再使用
func RedisGetStringCall ¶
func RedisGetStringCall(client *GsRedis, key string, call func() string, expire time.Duration) string
RedisGetStringCall 获取redis中的数据 @deprecated 不再使用
func RedisGetStringCallE ¶
func RedisGetStringCallE(client *GsRedis, key string, call func() string, expire time.Duration) (string, error)
RedisGetStringCallE 获取redis中的数据 @deprecated 不再使用
func RedisHash ¶
func RedisHash(client *GsRedis, key, subKey string, call func() map[string]string, expire time.Duration) string
RedisHash 获取hash中的某一个值 @deprecated 不再使用
func RedisHashAll ¶
func RedisHashAll(client *GsRedis, key string, call func() map[string]string, expire time.Duration) map[string]string
RedisHashAll 获取hash中的所有值 @deprecated 不再使用
func RedisHashAllE ¶
func RedisHashAllE(client *GsRedis, key string, call func() map[string]string, expire time.Duration) (map[string]string, error)
RedisHashAllE 获取hash中的所有值 @deprecated 不再使用
func RedisHashE ¶
func RedisHashE(client *GsRedis, key, subKey string, call func() map[string]string, expire time.Duration) (string, error)
RedisHashE 获取hash中的某一个值 @deprecated 不再使用
func RedisKeyExist ¶
RedisKeyExist 判断key是否存在 @deprecated 不再使用
func RedisSetExpire ¶
RedisSetExpire 设置缓存有效期 @deprecated 不再使用
func RedisSetNx ¶
RedisSetNx 获取锁 @deprecated 不再使用
Types ¶
type GsMysql ¶
type GsMysql struct {
MysqlConfig *MysqlConfig
GsLog *gstool.GsSlog
Ssh *gsssh.SshConfig
// contains filtered or unexported fields
}
func NewMysql ¶
func NewMysql(config *MysqlConfig, autoTransType bool) *GsMysql
func (*GsMysql) InsertBySql ¶
InsertBySql 插入
func (*GsMysql) QueryBySql ¶
QueryBySql 获取多行数据
func (*GsMysql) QuickCreate ¶
QuickCreate 快速根据map插入
func (*GsMysql) QuickDelete ¶
QuickDelete 快速删除数据
func (*GsMysql) QuickQuery ¶
QuickQuery 快速查询数据
func (*GsMysql) QuickUpdate ¶
func (h *GsMysql) QuickUpdate(tableName string, where map[string]interface{}, update map[string]interface{}) *SqlQuick
QuickUpdate 快速更新
func (*GsMysql) SetOpenFunc ¶
func (*GsMysql) TableDetail ¶
TableDetail 查询表的信息
type GsPgsql ¶
type GsPgsql struct {
PgsqlConfig *PgsqlConfig
GsLog *gstool.GsSlog
Ssh *gsssh.SshConfig
// contains filtered or unexported fields
}
func NewPgsql ¶
func NewPgsql(config *PgsqlConfig, autoTransType bool) *GsPgsql
func (*GsPgsql) InsertBySql ¶
InsertBySql 插入
func (*GsPgsql) QueryBySql ¶
QueryBySql 获取多行数据
func (*GsPgsql) QuickCreate ¶
QuickCreate 快速根据map插入
func (*GsPgsql) QuickDelete ¶
QuickDelete 快速删除数据
func (*GsPgsql) QuickQuery ¶
QuickQuery 快速查询数据
func (*GsPgsql) QuickUpdate ¶
func (h *GsPgsql) QuickUpdate(tableName string, where map[string]interface{}, update map[string]interface{}) *SqlQuick
QuickUpdate 快速更新
func (*GsPgsql) SetOpenFunc ¶
func (*GsPgsql) TableDetail ¶
TableDetail 查询表的信息
type GsRedis ¶
type GsRedis struct {
RedisConfig *RedisConfig
Client *redis.Client
Ssh *gsssh.SshConfig
}
func NewRedis ¶
func NewRedis(config *RedisConfig) *GsRedis
type GsSqlite ¶
type GsSqlite struct {
DbPath string
GsLog *gstool.GsSlog
// contains filtered or unexported fields
}
func (*GsSqlite) InsertBySql ¶
InsertBySql 插入
func (*GsSqlite) QueryBySql ¶
QueryBySql 获取多行数据
func (*GsSqlite) QuickCreate ¶
QuickCreate 快速根据map插入
func (*GsSqlite) QuickDelete ¶
QuickDelete 快速删除数据
func (*GsSqlite) QuickQuery ¶
QuickQuery 快速查询数据
func (*GsSqlite) QuickUpdate ¶
func (h *GsSqlite) QuickUpdate(tableName string, where map[string]interface{}, update map[string]interface{}) *SqlQuick
QuickUpdate 快速更新
func (*GsSqlite) TableDetail ¶
TableDetail 查询表的信息
type MysqlConfig ¶
type MysqlConfig struct {
Name string `json:"name"`
Host string `json:"host"`
Port int64 `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
Dbname string `json:"dbname"`
MaxOpenConns int `json:"maxOpenConns"` //最大连接池连接数量
MaxIdleConns int `json:"maxIdleConns"` //最大可空闲连接数
MaxLifetimeSecond int `json:"maxLifetimeSecond"` //链接重置时间 秒
}
type PgsqlConfig ¶
type PgsqlConfig struct {
Name string `json:"name"`
Host string `json:"host"`
Port int64 `json:"port"`
Username string `json:"username"`
Password string `json:"password"`
Dbname string `json:"dbname"`
PoolSize int `json:"poolsize"`
MaxOpenConns int `json:"maxOpenConns"`
MaxIdleConns int `json:"maxIdleConns"`
MaxLifetimeSecond int `json:"maxLifetimeSecond"` //链接重置时间 秒
}
type RedisConfig ¶
type RedisConfig struct {
Name string `json:"name"`
Host string `json:"host"`
Port int64 `json:"port"`
Password string `json:"password"`
Default int `json:"default"`
Username string `json:"userName"`
MaxOpenConns int `json:"maxOpenConns"` //最大连接池连接数量
MaxIdleConns int `json:"maxIdleConns"` //最大可空闲连接数
MaxLifetimeSecond int64 `json:"maxLifetimeSecond"` //连接的最大生存时间
}
type SqlFormat ¶
type SqlFormat struct {
// contains filtered or unexported fields
}
func NewSqlFormat ¶
func (*SqlFormat) FormatInsert ¶
func (h *SqlFormat) FormatInsert(tableName string, insert map[string]any) (string, string, []any, error)
FormatInsert 仅支持quick create
type SqlQuick ¶
func (*SqlQuick) InsertBySql ¶
InsertBySql 插入
func (*SqlQuick) OffsetLimit ¶
func (*SqlQuick) QueryBySql ¶
QueryBySql 获取多行数据
func (*SqlQuick) QuickCreate ¶
func (*SqlQuick) QuickDelete ¶
QuickDelete 快速删除数据
func (*SqlQuick) QuickQuery ¶
func (*SqlQuick) QuickUpdate ¶
func (h *SqlQuick) QuickUpdate(tableName string, where map[string]interface{}, update map[string]interface{}) *SqlQuick
QuickUpdate 快速更新
func (*SqlQuick) TableColumnsMap ¶
TableColumnsMap 查询表的所有列 map[string]string