Exemplo n.º 1
0
Arquivo: cache.go Projeto: zoe527/go2o
func Initialize(kvStorage gof.Storage) {
	if kvStorage.DriverName() == storage.DriveRedisStorage {
		_kvCacheStorage = kvStorage
	} else {
		panic(errors.New("only support redis storage now."))
	}
}
Exemplo n.º 2
0
// 获取商户站点配置
func GetPartnerSiteConf(partnerId int) *partner.SiteConf {
	var v *partner.SiteConf
	var sto gof.Storage = GetKVS()
	var key string = GetPartnerSiteConfCK(partnerId)

	if sto.DriverName() == storage.DriveHashStorage {
		if obj, err := GetKVS().GetRaw(key); err != nil {
			v = obj.(*partner.SiteConf)
		}
	} else if sto.DriverName() == storage.DriveRedisStorage {
		sto.Get(key, &v)
	}

	if v == nil {
		if v = dps.PartnerService.GetSiteConf(partnerId); v != nil {
			sto.Set(key, v)
		}
	}
	return v
}
Exemplo n.º 3
0
// 获取商户信息缓存
func GetValuePartnerCache(partnerId int) *partner.ValuePartner {
	var v *partner.ValuePartner
	var sto gof.Storage = GetKVS()
	var key string = GetValuePartnerCacheCK(partnerId)

	if sto.DriverName() == storage.DriveHashStorage {
		if obj, err := GetKVS().GetRaw(key); err != nil {
			v = obj.(*partner.ValuePartner)
		}
	} else if sto.DriverName() == storage.DriveRedisStorage {
		sto.Get(key, &v)
	}

	if v == nil {
		var err error
		if v, err = dps.PartnerService.GetPartner(partnerId); err == nil {
			sto.Set(key, v)
		}

	}
	return v
}