@@ -74,6 +74,7 @@ func (p *TTLPolicy) IsExpired(obj *TimestampedEntry) bool {
74
74
type TimestampedEntry struct {
75
75
Obj interface {}
76
76
Timestamp time.Time
77
+ key string
77
78
}
78
79
79
80
// getTimestampedEntry returns the TimestampedEntry stored under the given key.
@@ -129,10 +130,8 @@ func (c *ExpirationCache) List() []interface{} {
129
130
130
131
list := make ([]interface {}, 0 , len (items ))
131
132
for _ , item := range items {
132
- obj := item .(* TimestampedEntry ).Obj
133
- if key , err := c .keyFunc (obj ); err != nil {
134
- list = append (list , obj )
135
- } else if obj , exists := c .getOrExpire (key ); exists {
133
+ key := item .(* TimestampedEntry ).key
134
+ if obj , exists := c .getOrExpire (key ); exists {
136
135
list = append (list , obj )
137
136
}
138
137
}
@@ -154,7 +153,7 @@ func (c *ExpirationCache) Add(obj interface{}) error {
154
153
c .expirationLock .Lock ()
155
154
defer c .expirationLock .Unlock ()
156
155
157
- c .cacheStorage .Add (key , & TimestampedEntry {obj , c .clock .Now ()})
156
+ c .cacheStorage .Add (key , & TimestampedEntry {obj , c .clock .Now (), key })
158
157
return nil
159
158
}
160
159
@@ -187,7 +186,7 @@ func (c *ExpirationCache) Replace(list []interface{}, resourceVersion string) er
187
186
if err != nil {
188
187
return KeyError {item , err }
189
188
}
190
- items [key ] = & TimestampedEntry {item , ts }
189
+ items [key ] = & TimestampedEntry {item , ts , key }
191
190
}
192
191
c .expirationLock .Lock ()
193
192
defer c .expirationLock .Unlock ()
0 commit comments