Beispiel #1
0
// 汇总信息
func (this *MemberC) Summary(ctx *web.Context) {
	memberId := this.GetMemberId(ctx)
	var updateTime int64 = dps.MemberService.GetMemberLatestUpdateTime(memberId)
	var v *dto.MemberSummary = new(dto.MemberSummary)
	var key = fmt.Sprintf("cache:member:summary:%d", memberId)
	if cache.GetKVS().Get(key, &v) != nil || v.UpdateTime < updateTime {
		v = dps.MemberService.GetMemberSummary(memberId)
		cache.GetKVS().SetExpire(key, v, 3600*48) // cache 48 hours
	}
	ctx.Response.JsonOutput(v)
}
Beispiel #2
0
// get summary of member,if dbGet will get summary from database.
func GetMemberSummary(memberId int, updateTime int) *dto.MemberSummary {
	sto := gof.CurrentApp.Storage()
	var kvMut int
	mutKey := fmt.Sprintf("%s%d", variable.KvMemberUpdateTime, memberId)
	kvMut, _ = sto.GetInt(mutKey)
	//get from redis
	var v *dto.MemberSummary = new(dto.MemberSummary)
	var key = fmt.Sprintf("cac:mm:summary:%d", memberId)
	if kvMut != 0 && kvMut == updateTime {
		if cache.GetKVS().Get(key, v) == nil {
			return v
		}
	}
	v = dps.MemberService.GetMemberSummary(memberId)
	sto.SetExpire(key, v, 3600*360) // cache 15 hours
	sto.SetExpire(mutKey, v.UpdateTime, 3600*400)
	return v
}
Beispiel #3
0
func getMemberAccount(memberId int, updateTime int) *member.AccountValue {
	sto := gof.CurrentApp.Storage()
	var kvAut int
	autKey := fmt.Sprintf("%s%d", variable.KvAccountUpdateTime, memberId)
	kvAut, _ = sto.GetInt(autKey)
	//get from redis
	var v *member.AccountValue = new(member.AccountValue)
	var key = fmt.Sprintf("cac:mm:acc:%d", memberId)
	if kvAut != 0 && kvAut == updateTime {
		if cache.GetKVS().Get(key, v) == nil {
			return v
		}
	}
	v = dps.MemberService.GetAccount(memberId)
	sto.SetExpire(key, v, 3600*360) // cache 15 hours
	sto.SetExpire(autKey, v.UpdateTime, 3600*400)

	return v

}