marcoarment / Blackbird

MIT License
926 stars 29 forks source link

Is there a way to disable caching for a specific query? #26

Closed r-token closed 7 months ago

r-token commented 7 months ago

Hi there.

We have a specific query that retrieves data from multiple tables. This query is run immediately after updating a property in one of those tables.

However, we've noticed that, occasionally, the query returns stale data, returning what appears to be a cached/previous value instead of the recently-updated value.

Is there a way to disable caching for this specific query? If not, do you have any suggestions for how we might work around this?

marcoarment commented 7 months ago

Hi! This should not be possible — there isn't much caching in Blackbird, and the caching that's there should automatically flush its contents after any relevant write.

Is there any way you could show the relevant parts of the code here, or even better, a sample project that reproduces the problem, so we can determine if it's a bug?

r-token commented 7 months ago

My mistake! After some more digging throughout the week I found the issue. It is on our end.

A specific API request we were making was the source of the stale data. We make that GET request shortly after updating the property in Blackbird, and then upsert the stale API response data back into Blackbird - thus overwriting the local change we had just made. I mistook that for a caching problem.

Sorry for the false alarm. Hope you didn't spend much time looking into this. Love the library! We've found it much more flexible than SwiftData. Thank you for making it.

marcoarment commented 7 months ago

Happy to "help" (by doing nothing)! Glad you found the problem, and thanks for the kind words.