|
|
@@ -107,8 +107,16 @@ func AccessRecords(c *gin.Context) { |
|
|
|
|
|
|
|
user := svc.GetUser(c) |
|
|
|
date := time.Now().Format("2006-01-02") |
|
|
|
|
|
|
|
cacheKey := fmt.Sprintf(md.UserAccessRecordsKey, date, req.Index) |
|
|
|
if !cache.Exists(cacheKey) { |
|
|
|
ttl := 24 * 60 * 60 // 记录保存24小时 |
|
|
|
_, err := cache.SetEx(cacheKey, nil, ttl) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
get, err1 := cache.GetBit(cacheKey, user.Id) |
|
|
|
if err1 != nil || get == 0 { |
|
|
|
recordsDb := implement.NewEggAccessRecordsDb(db.Db) |
|
|
@@ -128,14 +136,8 @@ func AccessRecords(c *gin.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
ttl := 24 * 60 * 60 // 记录保存24小时 |
|
|
|
_, err = cache.SetBit(cacheKey, user.Id, 1) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
_, err = cache.Expire(cacheKey, ttl) |
|
|
|
_, err = cache.SetBit(cacheKey, user.Id, 1) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
|