Created
January 22, 2014 13:58
-
-
Save mathieuancelin/8559165 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So what happens if something else tries to update "mykey" while the atomic update is running?