database

package module
v0.0.0-...-63f634b Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2021 License: GPL-3.0 Imports: 14 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-db

golang数据库

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//存储缓存数据加载情况,数据库和缓存数据量一致为真
	SyncCache = make(map[string]bool)
	//是否使用缓存
	UseRedcache = true
)

Functions

func GetIdleConn

func GetIdleConn() (int, int, int, int, int)

func Mysql

func Mysql() (mysql *gorm.DB, err error)

func Open

func Open(dbType []string)

Types

type Condition

type Condition struct {
	Key   string
	Op    string
	Value interface{}
}

func (*Condition) ToString

func (ct *Condition) ToString(tablename string) string

type Database

type Database struct {
	// contains filtered or unexported fields
}

func (*Database) Count

func (m *Database) Count() (count, cacheCount int, err error)

Count Count

func (*Database) Create

func (m *Database) Create(u interface{}) (i interface{}, err error)

Create Create

func (*Database) Delete

func (m *Database) Delete(u interface{}) (b bool, err error)

Delete Delete

func (*Database) Find

func (m *Database) Find() (replys interface{}, count int, err error)

Find Find

func (*Database) Limit

func (m *Database) Limit(limit interface{}) *Database

func (*Database) Model

func (m *Database) Model(model interface{}) *Database

func (*Database) Offset

func (m *Database) Offset(offset interface{}) *Database

func (*Database) Order

func (m *Database) Order(order interface{}) *Database

func (*Database) Update

func (m *Database) Update(u interface{}) (i interface{}, err error)

Update Update

func (*Database) Where

func (m *Database) Where(where interface{}) *Database

type RedCache

type RedCache struct {
	// contains filtered or unexported fields
}

func New

func New() (redCache *RedCache)

func (*RedCache) BatchCreate

func (rc *RedCache) BatchCreate(m []interface{}) (err error)

func (*RedCache) Count

func (rc *RedCache) Count() (count int, err error)

func (*RedCache) Create

func (rc *RedCache) Create() (err error)

func (*RedCache) Delete

func (rc *RedCache) Delete() (err error)

func (*RedCache) GetSyncStatus

func (rc *RedCache) GetSyncStatus() (status map[string]bool, err error)

func (*RedCache) Limit

func (rc *RedCache) Limit(limit interface{}) *RedCache

func (*RedCache) Model

func (rc *RedCache) Model(model interface{}) *RedCache

func (*RedCache) Offset

func (rc *RedCache) Offset(offset interface{}) *RedCache

func (*RedCache) OrderBy

func (rc *RedCache) OrderBy(orderBy interface{}) *RedCache

func (*RedCache) Select

func (rc *RedCache) Select() (reply []interface{}, err error)

Select

func (*RedCache) SetSyncStatus

func (rc *RedCache) SetSyncStatus(status map[string]bool) (reply interface{}, err error)

设置同步状态

func (*RedCache) Update

func (rc *RedCache) Update() (err error)

func (*RedCache) Where

func (rc *RedCache) Where(where ...Condition) *RedCache

type RedisDB

type RedisDB struct {
	DBNum int
}

RedisDB redis 基础类

func GetRedisDB

func GetRedisDB() *RedisDB

连接到Redis数据库 num 是数据库编号

func (*RedisDB) Bool

func (redisDB *RedisDB) Bool(arg interface{}) bool

Bool 转换redis数据为Bool型,默认是uint8数组

func (*RedisDB) Del

func (redisDB *RedisDB) Del(key string) (reply interface{}, err error)

Del 删除key

func (*RedisDB) DelKey

func (redisDB *RedisDB) DelKey(key string)

DelKey 删除key

func (*RedisDB) Evalsha

func (redisDB *RedisDB) Evalsha(args ...interface{}) (reply interface{}, err error)

Evalsha 执行lua脚本

func (*RedisDB) Exists

func (redisDB *RedisDB) Exists(key string) (has bool, err error)

EXISTS key 是否存在

func (*RedisDB) Expire

func (redisDB *RedisDB) Expire(key string, time int)

Expire 设置 key 的过期时间

func (*RedisDB) Get

func (redisDB *RedisDB) Get(key string) (reply interface{}, err error)

Get 获取String型数据

func (*RedisDB) Hdel

func (redisDB *RedisDB) Hdel(key string, field interface{}) error

Hdel 删除Hash型数据

func (*RedisDB) Hexists

func (redisDB *RedisDB) Hexists(key, field interface{}) (has bool, err error)

Hexists 判断field是否存在

func (*RedisDB) Hget

func (redisDB *RedisDB) Hget(key string, value interface{}) (reply interface{}, err error)

Hget 获取Hash型数据

func (*RedisDB) Hgetall

func (redisDB *RedisDB) Hgetall(key string) []interface{}

Hgetall 批量获取Hash型数据

func (*RedisDB) Hkeys

func (redisDB *RedisDB) Hkeys(key string) []interface{}

Hkeys 获取Hash型数据所有field

func (*RedisDB) Hlen

func (redisDB *RedisDB) Hlen(key string) int

Hlen hash的数量

func (*RedisDB) Hmget

func (redisDB *RedisDB) Hmget(field ...interface{}) ([]interface{}, error)

Hmget 批量获取Hash型数据

func (*RedisDB) Hmset

func (redisDB *RedisDB) Hmset(field ...interface{}) error

Hmset 批量存储Hash型数据

func (*RedisDB) Hset

func (redisDB *RedisDB) Hset(key string, field, value interface{}) error

Hset 存储Hash型数据

func (*RedisDB) Hsetappend

func (redisDB *RedisDB) Hsetappend(key string, field string, value string)

Hsetappend 存储Hash型数据,把字符串用逗号分割

func (*RedisDB) Hvals

func (redisDB *RedisDB) Hvals(key string) []interface{}

Hvals 获取Hash型数据所有值

func (*RedisDB) Incr

func (redisDB *RedisDB) Incr() int

Incr 自增数值

func (*RedisDB) Info

func (redisDB *RedisDB) Info() (reply interface{}, err error)

查看redis信息

func (*RedisDB) Keys

func (redisDB *RedisDB) Keys(rex string) []string

Keys 获取符合条件的key

func (*RedisDB) Llen

func (redisDB *RedisDB) Llen(key interface{}) int

Llen 获取List型数据数量

func (*RedisDB) Lpush

func (redisDB *RedisDB) Lpush(args ...interface{})

Lpush 存储List型数据

func (*RedisDB) Lrange

func (redisDB *RedisDB) Lrange(args ...interface{}) []interface{}

Lrange 获取List型数据

func (*RedisDB) Psetex

func (redisDB *RedisDB) Psetex(value ...interface{}) (reply interface{}, err error)

Psetex 存储String型数据

func (*RedisDB) Sadd

func (redisDB *RedisDB) Sadd(value ...interface{}) (err error)

Sadd 存储Set型数据

func (*RedisDB) ScriptRun

func (redisDB *RedisDB) ScriptRun(s string, args ...interface{}) (err error)

ScriptLoad 加载lua脚本

func (*RedisDB) Set

func (redisDB *RedisDB) Set(value ...interface{}) (reply interface{}, err error)

Set 存储String型数据

func (*RedisDB) Smembers

func (redisDB *RedisDB) Smembers(key, value interface{}) (reply interface{}, err error)

Sadd 存储Set型数据

func (*RedisDB) String

func (redisDB *RedisDB) String(arg interface{}) string

String 转换redis数据为字符串型,默认是uint8数组

func (*RedisDB) Strings

func (redisDB *RedisDB) Strings(arg interface{}) []string

Strings 转换redis数据为字符串型,默认是uint8数组

func (*RedisDB) Type

func (redisDB *RedisDB) Type(key string) string

Type 返回 key 所储存的值的类型

func (*RedisDB) Zadd

func (redisDB *RedisDB) Zadd(key string, sort int, value interface{}) (err error)

Zadd 存储sortset型数据

func (*RedisDB) Zadds

func (redisDB *RedisDB) Zadds(value ...interface{}) (err error)

Zadd 存储sortset型数据

func (*RedisDB) Zcard

func (redisDB *RedisDB) Zcard(key string) (count int, err error)

Zcard 获取sortset型数据数量

func (*RedisDB) Zdelete

func (redisDB *RedisDB) Zdelete(key, member string) error

Zdelete 删除sortset型数据

func (*RedisDB) Zinterstore

func (redisDB *RedisDB) Zinterstore(key ...interface{}) error

Zinterstore 多个key的交集

func (*RedisDB) Zrange

func (redisDB *RedisDB) Zrange(key string, start, end interface{}) ([]interface{}, error)

Zrange 获取sortset型数据

func (*RedisDB) ZrangeByLex

func (redisDB *RedisDB) ZrangeByLex(args ...interface{}) []interface{}

ZrangeByLex 获取sortset型数据,参数中包含查询字符,类似于like

func (*RedisDB) ZrangeByScore

func (redisDB *RedisDB) ZrangeByScore(args ...interface{}) []interface{}

ZrangeByScore 获取sortset型数据

func (*RedisDB) Zrank

func (redisDB *RedisDB) Zrank(args ...interface{}) interface{}

Zrank 返回指定key的索引未知,空为没有找到

func (*RedisDB) Zrem

func (redisDB *RedisDB) Zrem(key string, args ...interface{}) (err error)

Zrem 删除sortset成员

func (*RedisDB) Zrevrange

func (redisDB *RedisDB) Zrevrange(key string, start, end interface{}) ([]interface{}, error)

Zrevrange 获取sortset型数据,从大到小

func (*RedisDB) ZrevrangeStrings

func (redisDB *RedisDB) ZrevrangeStrings(args ...interface{}) []string

ZrevrangeStrings 获取sortset型数据,从大到小,转化成字符串

func (*RedisDB) Zunionstore

func (redisDB *RedisDB) Zunionstore(args ...interface{})

Zunionstore 合并多个sortset

type StructField

type StructField struct {
	TableName string
	Name      string
	Tags      map[string]map[string]string
	Index     map[string]string
	IndexKv   map[string]interface{}
}

Jump to

Keyboard shortcuts

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