(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestCache_Basic(t *testing.T) { |
| 12 | interval := 200 * time.Millisecond |
| 13 | ttl := 20 * time.Millisecond |
| 14 | c := New(interval) |
| 15 | c.Put("int", 1, ttl) |
| 16 | c.Put("string", "a", ttl) |
| 17 | |
| 18 | i := c.Get("int") |
| 19 | assert.Equal(t, i.(int), 1, "should recv 1") |
| 20 | |
| 21 | s := c.Get("string") |
| 22 | assert.Equal(t, s.(string), "a", "should recv 'a'") |
| 23 | } |
| 24 | |
| 25 | func TestCache_TTL(t *testing.T) { |
| 26 | interval := 200 * time.Millisecond |