chore: update server services

This commit is contained in:
Steven
2023-09-22 07:44:44 +08:00
parent 790a8a2e17
commit 92fba82927
9 changed files with 143 additions and 85 deletions

View File

@@ -0,0 +1,24 @@
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)
}