- 将Redis连接方式改为连接池模式,提升连接复用效率 - 修复缓存注释错误,统一标识数据库缓存逻辑 - 添加数据检索结果非空验证,避免空指针异常 - 在数据库操作中添加读写锁保护,确保并发安全性 - 实现数据库查询和执行操作的重试机制,增强稳定性 - 更新配置文件中的缓存和数据库设置,优化缓存策略 - 重构README文档,补充框架特性和性能测试数据 - 添加示例路由配置,完善快速入门指南
30 lines
431 B
Go
30 lines
431 B
Go
package common
|
|
|
|
import (
|
|
"github.com/sirupsen/logrus"
|
|
"sync"
|
|
)
|
|
|
|
// Error 框架层处理错误
|
|
type Error struct {
|
|
Logger *logrus.Logger
|
|
error
|
|
mu sync.RWMutex
|
|
}
|
|
|
|
func (that *Error) GetError() error {
|
|
that.mu.RLock()
|
|
defer that.mu.RUnlock()
|
|
return that.error
|
|
}
|
|
|
|
func (that *Error) SetError(err error) {
|
|
that.mu.Lock()
|
|
that.error = err
|
|
that.mu.Unlock()
|
|
|
|
if that.Logger != nil && err != nil {
|
|
that.Logger.Warn(err)
|
|
}
|
|
}
|