|
@@ -5,20 +5,19 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
func (this *CacheBlocks) GetBlock1(host, url string) (template.HTML, bool) {
|
|
func (this *CacheBlocks) GetBlock1(host, url string) (template.HTML, bool) {
|
|
- this.mutex.Lock()
|
|
|
|
|
|
+ this.Lock()
|
|
|
|
+ defer this.Unlock()
|
|
if mapCache, ok := this.cacheBlocks[host]; ok {
|
|
if mapCache, ok := this.cacheBlocks[host]; ok {
|
|
if data, ok := mapCache.CacheBlock1[url]; ok {
|
|
if data, ok := mapCache.CacheBlock1[url]; ok {
|
|
- this.mutex.Unlock()
|
|
|
|
return data, ok
|
|
return data, ok
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- this.mutex.Unlock()
|
|
|
|
return template.HTML(""), false
|
|
return template.HTML(""), false
|
|
}
|
|
}
|
|
|
|
|
|
func (this *CacheBlocks) SetBlock1(host, url string, data template.HTML) {
|
|
func (this *CacheBlocks) SetBlock1(host, url string, data template.HTML) {
|
|
- this.mutex.Lock()
|
|
|
|
|
|
+ this.Lock()
|
|
|
|
+ defer this.Unlock()
|
|
this.prepare(host)
|
|
this.prepare(host)
|
|
this.cacheBlocks[host].CacheBlock1[url] = data
|
|
this.cacheBlocks[host].CacheBlock1[url] = data
|
|
- this.mutex.Unlock()
|
|
|
|
}
|
|
}
|