Created
October 30, 2013 22:19
-
-
Save mathieuancelin/7241349 to your computer and use it in GitHub Desktop.
Introducing Capped buckets
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
object Application extends Controller { | |
def bucket = Couchbase.cappedBucket("default", 100) | |
def data = Action.async { | |
import org.ancelin.play2.couchbase.CouchbaseRWImplicits.documentAsJsObjectReader | |
val enumerator = bucket.tail[JsObject]() | |
enumerator.map( Ok.chunked( _ ) ) | |
} | |
def insert = Action.async(parse.json) { request => | |
import org.ancelin.play2.couchbase.CouchbaseRWImplicits.jsObjectToDocumentWriter | |
bucket.insert[JsObject](UUID.randomUUID().toString, request.body.as[JsObject]).map(s => Ok(Json.obj("status" -> s.getMessage))) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment