-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement bc shim for old handler package
- Loading branch information
Showing
5 changed files
with
315 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package lru | ||
|
||
import ( | ||
"github.com/99designs/gqlgen/graphql" | ||
lru "github.com/hashicorp/golang-lru" | ||
) | ||
|
||
type LRU struct { | ||
lru *lru.Cache | ||
} | ||
|
||
var _ graphql.Cache = &LRU{} | ||
|
||
func New(size int) *LRU { | ||
cache, err := lru.New(size) | ||
if err != nil { | ||
// An error is only returned for non-positive cache size | ||
// and we already checked for that. | ||
panic("unexpected error creating cache: " + err.Error()) | ||
} | ||
return &LRU{cache} | ||
} | ||
|
||
func (l LRU) Get(key string) (value interface{}, ok bool) { | ||
return l.lru.Get(key) | ||
} | ||
|
||
func (l LRU) Add(key string, value interface{}) { | ||
l.lru.Add(key, value) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.