|
|
|
@ -9,7 +9,6 @@ import (
|
|
|
|
|
"dsBaseRpc/Utils/RedisUtil"
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
|
|
|
|
"github.com/go-redis/redis/v7"
|
|
|
|
|
"github.com/xormplus/builder"
|
|
|
|
|
"reflect"
|
|
|
|
|
"strconv"
|
|
|
|
@ -124,25 +123,15 @@ func batchWriteRedis(list []map[string]interface{}, m Selector) {
|
|
|
|
|
时间:2020-02-05
|
|
|
|
|
*/
|
|
|
|
|
func batchReadRedis(ids []string, prefix string) ([]map[string]interface{}, []string) {
|
|
|
|
|
//1、创建管道
|
|
|
|
|
var list []*redis.StringCmd
|
|
|
|
|
pipe := RedisUtil.RedisClient.Pipeline()
|
|
|
|
|
for i := 0; i < len(ids); i++ {
|
|
|
|
|
list = append(list, pipe.Get(prefix+ids[i]))
|
|
|
|
|
}
|
|
|
|
|
//2、执行管道
|
|
|
|
|
_, err := pipe.Exec()
|
|
|
|
|
if err != nil {
|
|
|
|
|
LogUtil.Error(ErrorConst.RedisError, err.Error())
|
|
|
|
|
}
|
|
|
|
|
//存在于缓存中的数据
|
|
|
|
|
var existList []map[string]interface{}
|
|
|
|
|
//不存在的主键有哪些
|
|
|
|
|
var notExistsIds []string
|
|
|
|
|
//3、输出结果
|
|
|
|
|
for i := 0; i < len(list); i++ {
|
|
|
|
|
_bean := list[i].Val()
|
|
|
|
|
if len(_bean) > 0 {
|
|
|
|
|
|
|
|
|
|
//1、创建管道
|
|
|
|
|
for i := 0; i < len(ids); i++ {
|
|
|
|
|
_bean, err := RedisUtil.GET(prefix + ids[i])
|
|
|
|
|
if err == nil {
|
|
|
|
|
n := CommonUtil.ConvertJsonStringToMap(_bean)
|
|
|
|
|
//找到了加到返回值列表中去
|
|
|
|
|
existList = append(existList, n)
|
|
|
|
@ -275,21 +264,21 @@ func pageCache(sql string) ([]map[string]interface{}, int32, error) {
|
|
|
|
|
功能:获取指定的表有哪些列
|
|
|
|
|
作者:黄海
|
|
|
|
|
时间:2020-6-12
|
|
|
|
|
*/
|
|
|
|
|
*/
|
|
|
|
|
func GetTableColumns(tableName string) ([]map[string]interface{}, error) {
|
|
|
|
|
sql := `select COLUMN_NAME from information_schema.COLUMNS where table_name = ? and table_schema = '` + ConfigUtil.MysqlDataBase + `'`
|
|
|
|
|
return db.SQL(sql,tableName).Query().List()
|
|
|
|
|
return db.SQL(sql, tableName).Query().List()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
功能:获取指定表的成批提交的大小
|
|
|
|
|
作者:黄海
|
|
|
|
|
时间:2020-06-12
|
|
|
|
|
*/
|
|
|
|
|
func GetTableBatchSize(tableName string)int{
|
|
|
|
|
var maxFileds= 65535
|
|
|
|
|
*/
|
|
|
|
|
func GetTableBatchSize(tableName string) int {
|
|
|
|
|
var maxFileds = 65535
|
|
|
|
|
//计算每个批次的大小
|
|
|
|
|
list,_:=GetTableColumns(tableName)
|
|
|
|
|
batchSize:=maxFileds/len(list)
|
|
|
|
|
list, _ := GetTableColumns(tableName)
|
|
|
|
|
batchSize := maxFileds / len(list)
|
|
|
|
|
return batchSize
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|