Move readme parts to their corresponding packages

This commit is contained in:
2018-07-03 20:33:55 +02:00
parent b4e6729fb0
commit 993153693a
6 changed files with 148 additions and 114 deletions
+20
View File
@@ -0,0 +1,20 @@
## File cache
Package `file_cache` implements a helper function that would cache results of
an expensive operation to a file. It would use file contents when the file exist
and won't call the function again unless the file is deleted.
```go
import "github.com/localhots/gobelt/filecache"
```
```go
ctx := context.Background()
var items []Item
filecache.Load(&items, "tmp/cache/items.json", func() {
err := conn.Query(ctx, "SELECT * FROM items").Load(&items).Error()
if err != nil {
log.Fatalf("Failed to load items: %v", err)
}
})
```