()
| 12 | } |
| 13 | |
| 14 | func (c *cache) get() Table { |
| 15 | now := time.Now().UTC().Unix() |
| 16 | last := atomic.LoadInt64(&c.lastUpdate) |
| 17 | if now-last > 30 && atomic.SwapInt64(&c.lastUpdate, now) == last { |
| 18 | go func() { |
| 19 | t, _ := Get() |
| 20 | c.table.Store(t) |
| 21 | }() |
| 22 | } |
| 23 | t, _ := c.table.Load().(Table) |
| 24 | return t |
| 25 | } |
| 26 | |
| 27 | var global = &cache{} |
| 28 |