Open davidnemec opened 9 months ago
hi @davidnemec! I think a small reproduction would be really helpful 😊
Did a small repository here.
Any updates on the issue?
The issue is that the redis cache does not return futures. To fix this, you'd need to manually wrap the cached results in futures again. Additionally, the cache needs a reference to the current event loop to create these futures.
However, we could improve usability here. There can be valid cases, like yours, where the cache cannot not store any futures, but just the loaded results. This would be a breaking change to the caching interface. Personally, I'd find a DataLoader cache working with AwaitableOrValue
a lot more intuitive than the current version.
What were the considerations and choices that led to the current design? /cc @DoctorJohn @patrick91
Describe the Bug
DataLoader custom cache cannot be used with redis even thought docs mentions it's possible.
Additional Context
The issue seems to be that dataloader calls get/set methods of custom cache class but expects/works only with Future type.
get
from cache expecting Future (here)set
set
to cache value arg is Future without result value itself (here), value to the Future is set later (here)set
should be called with real values to cache, not Future without resultI can help fixing this but I'm not sure what would be the proper way to handle this.
Upvote & Fund