Skip to content

Commit

Permalink
Merge pull request #1 from daangn/feat/context
Browse files Browse the repository at this point in the history
feat: support passing context
  • Loading branch information
hoonmin authored Dec 8, 2020
2 parents a41fca8 + 98773b6 commit fd50da2
Show file tree
Hide file tree
Showing 3 changed files with 204 additions and 83 deletions.
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,25 @@ After this command *gomemcache* is ready to use. Its source will be in:

## Example

import (
"github.com/bradfitz/gomemcache/memcache"
)

func main() {
mc := memcache.New("10.0.0.1:11211", "10.0.0.2:11211", "10.0.0.3:11212")
mc.Set(&memcache.Item{Key: "foo", Value: []byte("my value")})

it, err := mc.Get("foo")
...
}
```go
import (
"github.com/bradfitz/gomemcache/memcache"
)

func main() {
mc := memcache.New("10.0.0.1:11211", "10.0.0.2:11211", "10.0.0.3:11212")
mc.Set(&memcache.Item{Key: "foo", Value: []byte("my value")})

it, err := mc.Get("foo")

// With context
ctx, cancel := context.WithTimeout(2 * time.Second)
doLongTimeJob(ctx)
...
it, err = mc.GetWithContext(ctx, "bar")
...
}
```

## Full docs, see:

Expand Down
Loading

0 comments on commit fd50da2

Please sign in to comment.