attenuator sync
This commit is contained in:
parent
9481311d65
commit
6acbd2c3e2
|
@ -26,7 +26,7 @@ func (a *Attenuator) Do(key string, fun func()) bool {
|
||||||
|
|
||||||
val := a.memory.Get(key)
|
val := a.memory.Get(key)
|
||||||
if val == nil {
|
if val == nil {
|
||||||
go fun()
|
fun()
|
||||||
a.memory.Set(key, fmt.Sprintf("%d,1", time.Now().Unix()), time.Hour*time.Duration(24*365*100))
|
a.memory.Set(key, fmt.Sprintf("%d,1", time.Now().Unix()), time.Hour*time.Duration(24*365*100))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ func (a *Attenuator) Do(key string, fun func()) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
go fun()
|
fun()
|
||||||
a.memory.Set(key, fmt.Sprintf("%d,%d", nowTime, count), time.Hour*time.Duration(24*365*100))
|
a.memory.Set(key, fmt.Sprintf("%d,%d", nowTime, count), time.Hour*time.Duration(24*365*100))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue