mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-24 22:16:36 +08:00
实现缓存策略部分管理功能
This commit is contained in:
@@ -29,16 +29,16 @@ func NewSysSettingDAO() *SysSettingDAO {
|
||||
var SharedSysSettingDAO = NewSysSettingDAO()
|
||||
|
||||
// 设置配置
|
||||
func (this *SysSettingDAO) UpdateSetting(code string, valueJSON []byte, args ...interface{}) error {
|
||||
if len(args) > 0 {
|
||||
code = fmt.Sprintf(code, args...)
|
||||
func (this *SysSettingDAO) UpdateSetting(codeFormat string, valueJSON []byte, codeFormatArgs ...interface{}) error {
|
||||
if len(codeFormatArgs) > 0 {
|
||||
codeFormat = fmt.Sprintf(codeFormat, codeFormatArgs...)
|
||||
}
|
||||
|
||||
countRetries := 3
|
||||
var lastErr error
|
||||
for i := 0; i < countRetries; i++ {
|
||||
settingId, err := this.Query().
|
||||
Attr("code", code).
|
||||
Attr("code", codeFormat).
|
||||
ResultPk().
|
||||
FindInt64Col(0)
|
||||
if err != nil {
|
||||
@@ -48,7 +48,7 @@ func (this *SysSettingDAO) UpdateSetting(code string, valueJSON []byte, args ...
|
||||
if settingId == 0 {
|
||||
// 新建
|
||||
op := NewSysSettingOperator()
|
||||
op.Code = code
|
||||
op.Code = codeFormat
|
||||
op.Value = valueJSON
|
||||
_, err = this.Save(op)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user