How can I do that? (without changing the bucket type to Ephermal).
Sounds like Ephemeral is exactly what you want, if you don’t want any data to survive a restart!
I’m not aware of anything built into to Couchbase to auto-flush on a restart; but you could probably use the REST API to monitor when a restart occurs and issue a flush then.
However, if you are actually looking to not override data, you might want to look at the available concurrency controls
Add() method to only create a document if it doesn’t exist
Replace() method to only update an existing document (and not create)
- the use of Check-And-Set (CAS) to only update a document if the existing document is a specific revision.