Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrent access from multiple instances #389

Open
pardeike opened this issue Oct 24, 2018 · 1 comment
Open

Concurrent access from multiple instances #389

pardeike opened this issue Oct 24, 2018 · 1 comment

Comments

@pardeike
Copy link

I am looking for an implementation that allows us to use Apollo in multiple apps on iOS. Each app is going to talk to the same endpoint (or at least share object ids with the other apps) thus creating a seemless experience across apps. For that, and to allow for offline data, we would like to have one common file location that all apps (via App Groups) can cache the common entities.

However, I wonder if concurrent cache access and detecting changes is possible with hermes. I expect the access to at least overlap for a few seconds when you switch between apps that access or update the cache since iOS allows an app to continue execute in the background for a short period of time before it goes into hibernation.

I am willing to work with the source but I would like to get some feedback first before I dig deeper.

Thanks,
Andreas

@nevir
Copy link
Contributor

nevir commented Oct 31, 2018

I don't know if hermes will really solve this for you (no more than any other pure-JS cache implementation would, at least). Hermes (and Apollo's default implementation) load the entire cache into the memory; there's no back and forth with the disk beyond that point.

Since, AFAIK, you can't perform RPC between iOS apps: you would need to serialize the cache to disk (in a shared location, like one managed via an app group) when switching between apps.

I'm also assuming you're in a react native world? The other unfortunate reality is that shuffling data along RN's bridge is pretty expensive, so you want to minimize the amount of time spent hydrating/dehydrating cache data.

Due to all that, I don't think concurrent access is really feasible with hermes :(

That said, it might be feasible to refactor hermes to track diffs between past "save points", so that you can minimize the time spent saving/restoring state between app switches. Synchronizing those deltas across multiple apps might get tricky, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants