graph-gophers / dataloader

Implementation of Facebook's DataLoader in Golang
MIT License
1.2k stars 75 forks source link

How to implement BigCache? #78

Closed Alcoholhaha closed 2 years ago

Alcoholhaha commented 3 years ago

BigCache: func (c BigCache) Get(key string) ([]byte, error) { // ... } func (c BigCache) Set(key string, entry []byte) error { // ... }

But cache in dataloader: func (c NoCache) Get(context.Context, Key) (Thunk, bool) { return nil, false } func (c NoCache) Set(context.Context, Key, Thunk) { return }

So how do i implement BigCache in dataloader? How convert Thunk to []byte and []byte to Thunk? Looking forward to your reply!

pavelnikolov commented 2 years ago

See PR https://github.com/graph-gophers/dataloader/pull/84. It adds support for Generics and once merged you'll be able to use any type as the value - in your case Thunk[[]byte]