mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-19 19:24:01 +00:00
chore: update server services
This commit is contained in:
24
server/service/license/cache.go
Normal file
24
server/service/license/cache.go
Normal 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)
|
||||
}
|
Reference in New Issue
Block a user