litefs icon indicating copy to clipboard operation
litefs copied to clipboard

Support weaker consistency models

Open kentcdodds opened this issue 1 year ago • 11 comments

I believe there's an issue open about this somewhere, but I can't find it.

Here's my use case:

I'm using SQLite to cache a lot of things in my app like third party APIs and slow queries. Here are two conflicting problems:

  1. I can't use LiteFS for this cache because I write to this cache during GET requests all the time and I don't want to replay requests to the primary to update the cache. It would undo the benefits of multi-region because almost every request would be replayed.
  2. The caches can (and do) diverge. So a user can hit refresh and see different data because the second cache has stale data that hasn't been refreshed yet. On top of that, when I want to trigger a cache revalidation explicitly, I will have to trigger it across all regions which is a big pain.

Write speed is not important for this cache (I can fire-and-forget), so I'd like to be able to support writes from any region for this specific database. In my use case I'll need this support to not be at the global litefs level, but at the specific database level. This is because I also have another sqlite database that serves as the actual data store for my app and write speed matters for that.

Let me know if you have questions or if I'm missing something. Thanks!

kentcdodds avatar Jan 22 '23 00:01 kentcdodds