Auto-flushing a couchbase bucket


#1

Hi…

I have a bucket of type “Couchbase” and I want to flush it when ever couchbase goes down (manually / crash) and then goes back up. (in case someone updated some information in the DB that didn’t overwrite Couchbase’s old document since he was down at the time).

How can I do that? (without changing the bucket type to Ephermal).


#2

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

  • the Add() method to only create a document if it doesn’t exist
  • the 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.

#3

Thanks but Ephermal is not what i’m looking for.
I need to run a N1QL query against that bucket so I need an index. I can’t do that in community with Ephermal.

And I really don’t want to create a monitoring service.

I was looking for a way to set a callback batch file on start / stop.