fixed possible nil panic when item is deleted immediately after being added

This commit is contained in:
Karl Seguin
2014-10-25 12:24:52 +07:00
parent b0e3fca0f6
commit 3a00ce8f0a
2 changed files with 18 additions and 1 deletions

View File

@@ -13,6 +13,15 @@ func Test_Cache(t *testing.T) {
Expectify(new(CacheTests), t)
}
func (c *CacheTests) DeletesAValue() {
cache := New(Configure())
cache.Set("spice", "flow", time.Minute)
cache.Set("worm", "sand", time.Minute)
cache.Delete("spice")
Expect(cache.Get("spice")).To.Equal(nil)
Expect(cache.Get("worm").(string)).To.Equal("sand")
}
func (c *CacheTests) GCsTheOldestItems() {
cache := New(Configure().ItemsToPrune(10))
for i := 0; i < 500; i++ {