Files
slogan/styleagent/agent/imagegen_cache.go
T

22 lines
440 B
Go

package agent
import "time"
// 效果图 URL 缓存(key: 方案内容 hash:角度,24h TTL,复用泛型 TTL 缓存)
var effectCache = NewTTLCache(24 * time.Hour)
// CacheGet 读取缓存 URL
func CacheGet(key string) (string, bool) {
v, ok := effectCache.Get(key)
if !ok {
return "", false
}
s, _ := v.(string)
return s, s != ""
}
// CacheSet 写入缓存 URL
func CacheSet(key, url string) {
effectCache.Set(key, url)
}