Beispiel #1
0
/**
减少时间
**/
func DecExpired(readyData *Entity.ReadyData, waitData *Entity.WaitData, key string, expired uint) error {
	//如果任务已经在ready中,就不需要处理
	if readyData.Isset(key) {
		return nil
	}
	//在wait队列中的,只更新到期时间
	if waitData.Isset(key) {
		waitData.DecExpired(key, expired)
		//存储数据
		Store.SetData(readyData, waitData)
		return nil
	}
	return Utils.LogErr(1001)
}
Beispiel #2
0
/**
删除一个任务,在两个列表里删,ready和wait
**/
func Del(readyData *Entity.ReadyData, waitData *Entity.WaitData, key string) error {
	if readyData.Isset(key) {
		readyData.Del(key)
		//存储数据
		Store.SetData(readyData, waitData)
		return nil
	}
	if waitData.Isset(key) {
		waitData.Del(key)
		//存储数据
		Store.SetData(readyData, waitData)
		return nil
	}
	return Utils.LogErr(1000)
}
Beispiel #3
0
/**
增加任务到期时间
**/
func AddExpired(readyData *Entity.ReadyData, waitData *Entity.WaitData, key string, expired uint) error {
	//增加到期时间,就从就绪队列中删除,并添加到wait队列中
	if readyData.Isset(key) {
		waitData.Add(key, (*readyData)[key].Value, (*readyData)[key].Expired)
		readyData.Del(key)
		//存储数据
		Store.SetData(readyData, waitData)
		return nil
	}
	//在wait队列中的,只更新到期时间
	if waitData.Isset(key) {
		waitData.AddExpired(key, expired)
		//存储数据
		Store.SetData(readyData, waitData)
		return nil
	}
	return Utils.LogErr(1001)
}