feat(docs): 完善达梦数据库支持文档
- 更新 .gitignore 文件,添加对 .sql 文件的忽略 - 移除 cache_db.go 中的调试日志相关代码,简化缓存操作逻辑 - 在多个文档中添加达梦 DM8 数据库的支持信息,包括配置、使用注意事项及示例 - 更新 QUICKSTART.md,明确支持的数据库类型及配置示例 - 在 ROADMAP.md 中记录达梦数据库完整支持的进展
This commit is contained in:
Vendored
-65
@@ -3,33 +3,12 @@ package cache
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
)
|
||||
|
||||
// debugLogDb 写入调试日志
|
||||
func debugLogDb(hypothesisId, location, message string, data map[string]interface{}) {
|
||||
// #region agent log
|
||||
logFile, _ := os.OpenFile(`d:\work\hotimev1.5\.cursor\debug.log`, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if logFile != nil {
|
||||
logEntry, _ := json.Marshal(map[string]interface{}{
|
||||
"sessionId": "cache-db-debug",
|
||||
"runId": "test-run",
|
||||
"hypothesisId": hypothesisId,
|
||||
"location": location,
|
||||
"message": message,
|
||||
"data": data,
|
||||
"timestamp": time.Now().UnixMilli(),
|
||||
})
|
||||
logFile.Write(append(logEntry, '\n'))
|
||||
logFile.Close()
|
||||
}
|
||||
// #endregion
|
||||
}
|
||||
|
||||
// 表名常量
|
||||
const (
|
||||
CacheTableName = "hotime_cache"
|
||||
@@ -614,13 +593,6 @@ func (that *CacheDb) CachesGet(keys []string) Map {
|
||||
return result
|
||||
}
|
||||
|
||||
// #region agent log
|
||||
debugLogDb("E", "cache_db.go:CachesGet:start", "CacheDb.CachesGet开始", map[string]interface{}{
|
||||
"keys_count": len(keys),
|
||||
"keys": keys,
|
||||
})
|
||||
// #endregion
|
||||
|
||||
tableName := that.getTableName()
|
||||
nowTime := Time2Str(time.Now())
|
||||
|
||||
@@ -630,36 +602,18 @@ func (that *CacheDb) CachesGet(keys []string) Map {
|
||||
"end_time[>]": nowTime,
|
||||
})
|
||||
|
||||
// #region agent log
|
||||
debugLogDb("E", "cache_db.go:CachesGet:afterSelect", "DB Select完成", map[string]interface{}{
|
||||
"table": tableName,
|
||||
"now_time": nowTime,
|
||||
"found_rows": len(cachedList),
|
||||
})
|
||||
// #endregion
|
||||
|
||||
for _, cached := range cachedList {
|
||||
valueStr := cached.GetString("value")
|
||||
if valueStr != "" {
|
||||
data, err := JsonToObj(valueStr)
|
||||
if err == nil {
|
||||
result[cached.GetString("key")] = data
|
||||
} else {
|
||||
// #region agent log
|
||||
debugLogDb("E", "cache_db.go:CachesGet:unmarshalError", "JSON解析失败", map[string]interface{}{
|
||||
"key": cached.GetString("key"),
|
||||
"error": err.Error(),
|
||||
})
|
||||
// #endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 兼容模式:新表没有的 key,回退读取老表
|
||||
if that.isCompatibleMode() {
|
||||
// #region agent log
|
||||
debugLogDb("E", "cache_db.go:CachesGet:compatMode", "兼容模式检查老表", nil)
|
||||
// #endregion
|
||||
for _, key := range keys {
|
||||
if _, exists := result[key]; !exists {
|
||||
legacyData := that.getLegacy(key)
|
||||
@@ -670,12 +624,6 @@ func (that *CacheDb) CachesGet(keys []string) Map {
|
||||
}
|
||||
}
|
||||
|
||||
// #region agent log
|
||||
debugLogDb("E", "cache_db.go:CachesGet:end", "CacheDb.CachesGet完成", map[string]interface{}{
|
||||
"result_count": len(result),
|
||||
})
|
||||
// #endregion
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -688,12 +636,6 @@ func (that *CacheDb) CachesSet(data Map, timeout ...int64) {
|
||||
return
|
||||
}
|
||||
|
||||
// #region agent log
|
||||
debugLogDb("A", "cache_db.go:CachesSet:start", "CacheDb.CachesSet开始", map[string]interface{}{
|
||||
"data_count": len(data),
|
||||
})
|
||||
// #endregion
|
||||
|
||||
// 计算过期时间
|
||||
var tim int64
|
||||
if len(timeout) > 0 && timeout[0] > 0 {
|
||||
@@ -710,13 +652,6 @@ func (that *CacheDb) CachesSet(data Map, timeout ...int64) {
|
||||
for key, value := range data {
|
||||
that.set(key, value, endTime)
|
||||
}
|
||||
|
||||
// #region agent log
|
||||
debugLogDb("A", "cache_db.go:CachesSet:end", "CacheDb.CachesSet完成", map[string]interface{}{
|
||||
"data_count": len(data),
|
||||
"end_time": Time2Str(endTime),
|
||||
})
|
||||
// #endregion
|
||||
}
|
||||
|
||||
// CachesDelete 批量删除缓存
|
||||
|
||||
Reference in New Issue
Block a user