- move Cacher from globals to api

- vendorPromotionID for CreatePromotion
- LockPromotionSkus
This commit is contained in:
gazebo
2018-11-07 13:17:25 +08:00
parent ee9b84bd80
commit 9bb30affc4
12 changed files with 291 additions and 163 deletions

View File

@@ -5,6 +5,7 @@ import (
"time"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
)
const (
@@ -15,16 +16,20 @@ func LockJdStoreSku(jdStoreID string, jdSkuID int64, expire time.Time) {
globals.SugarLogger.Debug(expire, " ", time.Now())
duration := expire.Sub(time.Now())
if duration > 0 {
globals.Cacher.Set(genCacheKey(jdStoreID, jdSkuID), 1, duration)
api.Cacher.Set(genCacheKey(jdStoreID, jdSkuID), 1, duration)
}
}
func UnlockJdStoreSku(jdStoreID string, jdSkuID int64) {
globals.Cacher.Del(genCacheKey(jdStoreID, jdSkuID))
api.Cacher.Del(genCacheKey(jdStoreID, jdSkuID))
}
func IsJdStoreSkuLocked(jdStoreID string, jdSkuID int64) bool {
return globals.Cacher.Get(genCacheKey(jdStoreID, jdSkuID)) != nil
return api.Cacher.Get(genCacheKey(jdStoreID, jdSkuID)) != nil
}
func ClearJdStoreSkuLock() {
api.Cacher.FlushKeys(cacheKeyPrefix)
}
func genCacheKey(jdStoreID string, jdSkuID int64) string {