Add keys method

This commit is contained in:
Santi 2019-11-03 11:41:21 +01:00
parent 46f4078530
commit 6b7005b04f
1 changed files with 10 additions and 0 deletions

View File

@ -1034,6 +1034,16 @@ func (c *cache) LoadFile(fname string) error {
return fp.Close()
}
func (c *cache) Keys() []string {
c.mu.RLock()
defer c.mu.RUnlock()
keys := make([]string, 0, len(c.items))
for k := range c.items {
keys = append(keys, k)
}
return keys
}
// Copies all unexpired items in the cache into a new map and returns it.
func (c *cache) Items() map[string]Item {
c.mu.RLock()