()
| 198 | } |
| 199 | |
| 200 | func (f *fileSystemCache) cleaner() { |
| 201 | d := f.expire / 2 |
| 202 | if d < time.Minute { |
| 203 | d = time.Minute |
| 204 | } |
| 205 | if d > time.Hour { |
| 206 | d = time.Hour |
| 207 | } |
| 208 | forceCleanCh := time.After(d) |
| 209 | |
| 210 | f.clean() |
| 211 | for { |
| 212 | select { |
| 213 | case <-time.After(time.Second): |
| 214 | // Clean cache only on cache size overflow. |
| 215 | stats := f.Stats() |
| 216 | if stats.Size > f.maxSize { |
| 217 | f.clean() |
| 218 | } |
| 219 | case <-forceCleanCh: |
| 220 | // Forcibly clean cache from expired items. |
| 221 | f.clean() |
| 222 | forceCleanCh = time.After(d) |
| 223 | case <-f.stopCh: |
| 224 | return |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | func (f *fileSystemCache) fileInfoPath(fi os.FileInfo) string { |
| 230 | return filepath.Join(f.dir, fi.Name()) |
no test coverage detected