How to save documents temporarily in the Couchbase server for sync only?

I am testing the Couchbase lite for a mobile app. So far, it works great. I have two questions about the Sync gateway:

  1. We must have a Couchbase Server to store the documents to enable sync between devices, right? Other posts here talk about the Sync gateway only saving documents in memory. I want to confirm it is still true in Sync Gateway 3.0.

  2. I don’t want to store the documents on the server forever, but we need the server to sync documents across devices. So, Is there such a feature to tell Couchbase to auto-purge the document when it knows the document already synced to all devices(active Couchbase lite clients?)

Thanks.

Couchbase Server is required when using Sync Gateway, correct. Couchbase Mobile also supports peer-to-peer replication between devices.

In general documents should to be retained on the server for as long as they are active on clients, unless you’re working in a peer-to-peer only deployment. Sync Gateway isn’t aware of the full set of client devices (and in addition whether any of those devices may have had their databases rebuilt by something like an application uninstall/reinstall), so it’s not possible to determine when the document is no longer ‘needed’ for client replication.

Hi, @adamf, thanks for your information.

I am aware of the p2p sync, I will try that soon.

My use case is, users want the sync feature (through our server), but they do not want to store the document forever. From what you mentioned, this may be the only solution I can think of for now:

  1. Track the information about how many active devices a user has. let’s say three devices, A, B, and C. (for active, we can think of it used within a month or year).
  2. Find the information about document synced information (I am wondering how to get it from Couchbase Server?).
  3. Remove the document from the Couchbase server if it synced to all active devices (A, B, and C).

So, my question is about step 2, can we get the synced information from Couchbase Server API or do we have to track devices and synced information on the devices by ourselves in the backend. Thanks.