23 lines
397 B
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()
|
|
}
|