DeletePrefix deletes all entries with the given prefix Returns number of entries deleted
(prefix string)
| 175 | // |
| 176 | // Returns number of entries deleted |
| 177 | func (c *Cache) DeletePrefix(prefix string) (deleted int) { |
| 178 | c.mu.Lock() |
| 179 | for key, entry := range c.cache { |
| 180 | if !strings.HasPrefix(key, prefix) { |
| 181 | continue |
| 182 | } |
| 183 | c.finalize(entry.value) |
| 184 | delete(c.cache, key) |
| 185 | deleted++ |
| 186 | } |
| 187 | c.mu.Unlock() |
| 188 | return deleted |
| 189 | } |
| 190 | |
| 191 | // Rename renames the item at oldKey to newKey. |
| 192 | // |