Use typed *Item in DeleteFunc
This commit is contained in:
@@ -107,17 +107,17 @@ func (_ *LayeredCacheTests) DeletesAFunc() {
|
||||
cache.Set("spice", "f", 6, time.Minute)
|
||||
Expect(cache.ItemCount()).To.Equal(6)
|
||||
|
||||
Expect(cache.DeleteFunc("spice", func(key string, item interface{}) bool {
|
||||
Expect(cache.DeleteFunc("spice", func(key string, item *Item) bool {
|
||||
return false
|
||||
})).To.Equal(0)
|
||||
Expect(cache.ItemCount()).To.Equal(6)
|
||||
|
||||
Expect(cache.DeleteFunc("spice", func(key string, item interface{}) bool {
|
||||
return item.(*Item).Value().(int) < 4
|
||||
Expect(cache.DeleteFunc("spice", func(key string, item *Item) bool {
|
||||
return item.Value().(int) < 4
|
||||
})).To.Equal(2)
|
||||
Expect(cache.ItemCount()).To.Equal(4)
|
||||
|
||||
Expect(cache.DeleteFunc("spice", func(key string, item interface{}) bool {
|
||||
Expect(cache.DeleteFunc("spice", func(key string, item *Item) bool {
|
||||
return key == "d"
|
||||
})).To.Equal(1)
|
||||
Expect(cache.ItemCount()).To.Equal(3)
|
||||
|
Reference in New Issue
Block a user