List retrieves a list of unexpired items. It purges the cache of expired items in the process.
()
| 125 | // List retrieves a list of unexpired items. It purges the cache of expired |
| 126 | // items in the process. |
| 127 | func (c *ExpirationCache) List() []interface{} { |
| 128 | items := c.cacheStorage.List() |
| 129 | |
| 130 | list := make([]interface{}, 0, len(items)) |
| 131 | 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 { |
| 136 | list = append(list, obj) |
| 137 | } |
| 138 | } |
| 139 | return list |
| 140 | } |
| 141 | |
| 142 | // ListKeys returns a list of all keys in the expiration cache. |
| 143 | func (c *ExpirationCache) ListKeys() []string { |
nothing calls this directly
no test coverage detected