|
@@ -11,6 +11,7 @@ import (
|
|
"regexp"
|
|
"regexp"
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
|
|
+ "sync"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
@@ -75,9 +76,13 @@ var TypeCodeMap = map[string]string{
|
|
var (
|
|
var (
|
|
redisLimitation = "limitation"
|
|
redisLimitation = "limitation"
|
|
cacheIndex = []byte{}
|
|
cacheIndex = []byte{}
|
|
|
|
+ cacheLock = sync.Mutex{}
|
|
)
|
|
)
|
|
|
|
|
|
func (s *Short) ClearCache() {
|
|
func (s *Short) ClearCache() {
|
|
|
|
+ defer util.Catch()
|
|
|
|
+ cacheLock.Lock()
|
|
|
|
+ defer cacheLock.Unlock()
|
|
log.Println("before cacheIndex:", string(cacheIndex))
|
|
log.Println("before cacheIndex:", string(cacheIndex))
|
|
if len(cacheIndex) > 0 {
|
|
if len(cacheIndex) > 0 {
|
|
cacheIndex = []byte{}
|
|
cacheIndex = []byte{}
|
|
@@ -143,10 +148,11 @@ func (s *Short) Article(contentType, stype, id string) error {
|
|
}
|
|
}
|
|
// 将页面内容返回给前端
|
|
// 将页面内容返回给前端
|
|
s.ResponseWriter.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
s.ResponseWriter.Header().Set("Content-Type", "text/html; charset=utf-8")
|
|
- //body, err := redis.GetBytes(redisLimitation, mobileHtmlKey)
|
|
|
|
|
|
+ cacheLock.Lock()
|
|
if len(cacheIndex) == 0 {
|
|
if len(cacheIndex) == 0 {
|
|
cacheIndex = loginPageInfo()
|
|
cacheIndex = loginPageInfo()
|
|
}
|
|
}
|
|
|
|
+ cacheLock.Unlock()
|
|
s.ResponseWriter.Write(cacheIndex)
|
|
s.ResponseWriter.Write(cacheIndex)
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|