Skip to content

Instantly share code, notes, and snippets.

@mathieuancelin
Created January 22, 2014 13:58
Show Gist options
  • Save mathieuancelin/8559165 to your computer and use it in GitHub Desktop.
Save mathieuancelin/8559165 to your computer and use it in GitHub Desktop.
case class MyData(uData: String, otherData: String)
object Application1 extends App {
// get a driver instance driver
val driver = ReactiveCouchbaseDriver()
// get the default bucket
val bucket = driver.bucket("default")
implicit val fmt = Json.format[MyData]
bucket.atomicallyUpdate[MyData]("myKey") { currentValue =>
val usefulData = currentValue.uData
WS.url(s"http://myWebservice.com/service?data=${usefulData}").get().map { value =>
usefulData.copy(uData = value)
}
}.onComplete {
case _ => driver.shutdown()
}
}
@frankandrobot
Copy link

So what happens if something else tries to update "mykey" while the atomic update is running?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment