Skip to content

Commit

Permalink
readme: minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
kukymbr committed Mar 4, 2024
1 parent 7facbf0 commit 15050df
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,35 +112,25 @@ scanner := filecache.NewScanner("/path/to/cache/dir")

err := scanner.Scan(func(entry filecache.ScanEntry) error {
// Do something with the found entry...
return nil
})
if err := nil {
// Handle the error...
// Handle the error...
}
```

### Removing the expired items

The expired cache items are removed by the `GarbageCollector`, assigned to the `FileCache` instance.

There are three types of the `GarbageCollector` adapters:
There are three predefined realizations of the `GarbageCollector`:

* `filecache.NewNopGarbageCollector()` — the `GarbageCollector` doing nothing, all the files are kept;
* `filecache.NewProbabilityGarbageCollector()` — the `GarbageCollector` running with the defined probability, used by default;
* `filecache.NewIntervalGarbageCollector()` — the `GarbageCollector` running by the time interval.

See the [gc.go's](gc.go) godocs for more info.

```go
// Initialize the scanner
scanner := filecache.NewScanner(fc.GetPath())

// Iterate
err = scanner.Scan(func(entry filecache.ScanEntry) error {
// Do some nice things...
return nil
})
```

## License

[MIT](/LICENSE).

0 comments on commit 15050df

Please sign in to comment.