CleanPrefix 根据前缀进行清除
(prefix string)
| 108 | |
| 109 | // CleanPrefix 根据前缀进行清除 |
| 110 | func (this *MemoryList) CleanPrefix(prefix string) error { |
| 111 | this.locker.RLock() |
| 112 | defer this.locker.RUnlock() |
| 113 | |
| 114 | // TODO 需要优化性能,支持千万级数据低于1s的处理速度 |
| 115 | for _, itemMap := range this.itemMaps { |
| 116 | for _, item := range itemMap { |
| 117 | if strings.HasPrefix(item.Key, prefix) { |
| 118 | item.ExpiresAt = 0 |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | return nil |
| 123 | } |
| 124 | |
| 125 | // CleanMatchKey 清理通配符匹配的缓存数据,类似于 https://*.example.com/hello |
| 126 | func (this *MemoryList) CleanMatchKey(key string) error { |