This repository has been archived on 2021-08-10. You can view files and clone it, but cannot push or open issues or pull requests.
gtools/tpl/cache.go

23 lines
397 B
Go

package tpl
import "html/template"
func setCache(name string, tpl template.Template) {
cacheMutex.Lock()
cache[name] = tpl
cacheMutex.Unlock()
}
func getCache(name string) (template.Template, bool) {
cacheMutex.RLock()
tpl, ok := cache[name]
cacheMutex.RUnlock()
return tpl, ok
}
func flushCache() {
cacheMutex.Lock()
cache = make(map[string]template.Template)
cacheMutex.Unlock()
}