Skip to content

Commit

Permalink
fixing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Randall committed Nov 29, 2017
1 parent aa342df commit beedcd5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DataLoader
[![GoDoc](https://godoc.org/github.com/nicksrandall/dataloader?status.svg)](https://godoc.org/github.com/nicksrandall/dataloader)
[![GoDoc](https://godoc.org/gopkg.in/nicksrandall/dataloader.v3?status.svg)](https://godoc.org/github.com/nicksrandall/dataloader)
[![Build Status](https://travis-ci.org/nicksrandall/dataloader.svg?branch=master)](https://travis-ci.org/nicksrandall/dataloader)
[![codecov](https://codecov.io/gh/nicksrandall/dataloader/branch/master/graph/badge.svg)](https://codecov.io/gh/nicksrandall/dataloader)

Expand All @@ -9,7 +9,7 @@ This is an implementation of [Facebook's DataLoader](https://github.com/facebook
This project is a work in progress. Feedback is encouraged.

## Install
`go get -u gopkg.in/nicksrandall/dataloader.v2`
`go get -u gopkg.in/nicksrandall/dataloader.v3`

## Usage
```go
Expand Down
6 changes: 3 additions & 3 deletions example/lru-cache/golang-lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Cache struct {
}

// Get gets an item from the cache
func (c *Cache) Get(key string) (dataloader.Thunk, bool) {
func (c *Cache) Get(_ context.Context, key string) (dataloader.Thunk, bool) {
v, ok := c.ARCCache.Get(key)
if ok {
return v.(dataloader.Thunk), ok
Expand All @@ -25,12 +25,12 @@ func (c *Cache) Get(key string) (dataloader.Thunk, bool) {
}

// Set sets an item in the cache
func (c *Cache) Set(key string, value dataloader.Thunk) {
func (c *Cache) Set(_ context.Context, key string, value dataloader.Thunk) {
c.ARCCache.Add(key, value)
}

// Delete deletes an item in the cache
func (c *Cache) Delete(key string) bool {
func (c *Cache) Delete(_ context.Context, key string) bool {
if c.ARCCache.Contains(key) {
c.ARCCache.Remove(key)
return true
Expand Down
6 changes: 3 additions & 3 deletions example/ttl-cache/go-cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Cache struct {
}

// Get gets a value from the cache
func (c *Cache) Get(key string) (dataloader.Thunk, bool) {
func (c *Cache) Get(_ context.Context, key string) (dataloader.Thunk, bool) {
v, ok := c.c.Get(key)
if ok {
return v.(dataloader.Thunk), ok
Expand All @@ -26,12 +26,12 @@ func (c *Cache) Get(key string) (dataloader.Thunk, bool) {
}

// Set sets a value in the cache
func (c *Cache) Set(key string, value dataloader.Thunk) {
func (c *Cache) Set(_ context.Context, key string, value dataloader.Thunk) {
c.c.Set(key, value, 0)
}

// Delete deletes and item in the cache
func (c *Cache) Delete(key string) bool {
func (c *Cache) Delete(_ context.Context, key string) bool {
if _, found := c.c.Get(key); found {
c.c.Delete(key)
return true
Expand Down

0 comments on commit beedcd5

Please sign in to comment.