Remove removes an entry from cache
(key string)
| 316 | |
| 317 | // Remove removes an entry from cache |
| 318 | func (fc *FileCache) Remove(key string) { |
| 319 | // First check if cache is closed |
| 320 | fc.closeMutex.RLock() |
| 321 | if fc.closed { |
| 322 | fc.closeMutex.RUnlock() |
| 323 | return |
| 324 | } |
| 325 | fc.closeMutex.RUnlock() |
| 326 | |
| 327 | // Write lock for cache access |
| 328 | fc.cacheMutex.Lock() |
| 329 | defer fc.cacheMutex.Unlock() |
| 330 | |
| 331 | // Remove from Olric cache |
| 332 | _, err := fc.cache.Delete(context.Background(), key) |
| 333 | if err != nil && err != olric.ErrKeyNotFound { |
| 334 | log.Printf("Error removing key %s from Olric cache: %v", key, err) |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | // RemoveAsync removes an entry from cache asynchronously using worker pool |
| 339 | func (fc *FileCache) RemoveAsync(key string) { |