2023-09-22 07:44:44 +08:00

25 lines
512 B
Go

package license
import (
"fmt"
"time"
"github.com/patrickmn/go-cache"
)
var (
licenseCache = cache.New(24*time.Hour, 24*time.Hour)
)
func SetLicenseCache(licenseKey, instanceName string, license LicenseKey) {
licenseCache.Set(fmt.Sprintf("%s-%s", licenseKey, instanceName), license, 24*time.Hour)
}
func GetLicenseCache(licenseKey, instanceName string) *LicenseKey {
cache, ok := licenseCache.Get(fmt.Sprintf("%s-%s", licenseKey, instanceName))
if !ok {
return nil
}
return cache.(*LicenseKey)
}