graph-gophers / dataloader

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

how to use redis as cache #91

Closed ffrankfeng closed 2 years ago

eaglemoor commented 2 years ago

U need to support dataloader.Cache interface.

rwrz commented 2 years ago

Isn't that easy. The cache interface returns a Thunk[V], which is like a "callback function". It is not possible to "encode" and save it on Redis. Based on this answer here, I was expecting it to be possible, but I just realize now that it won't be possible.

Is there a way to refactor the loader to save/load values and not functions?

eaglemoor commented 2 years ago

@rwrz u can use Redis cache in batch function, without cache in dataloader