Skip to content

Commit

Permalink
add simple example to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightning committed Jul 16, 2023
1 parent 7ac470f commit 6ba4794
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ A simple memoizer for Go.
[![Linter](https://goreportcard.com/badge/github.com/LightningDev1/go-memoizer?style=flat-square)](https://goreportcard.com/report/github.com/LightningDev1/go-memoizer)
[![Build status](https://github.com/LightningDev1/go-memoizer/actions/workflows/ci.yml/badge.svg)](https://github.com/LightningDev1/go-memoizer/actions)

```go
func expensiveFunction() *any {
// ...
}

var memoizer = memoizer.NewMemoizer(expensiveFunction, 10*time.Second)

for i := 0; i < 50; i++ {
value, err := memoizer.Get()

// ...
}
```

## Installation

```bash
Expand All @@ -14,4 +28,4 @@ go get github.com/LightningDev1/go-memoizer

## Usage

See [config example](./examples/config/main.go) for an example.
See [config example](./examples/config/main.go) for a complete example program.

0 comments on commit 6ba4794

Please sign in to comment.