mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-23 06:37:57 +00:00
25 lines
512 B
Go
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)
|
|
}
|