Skip to content

Instantly share code, notes, and snippets.

@mathieuancelin
Created October 30, 2013 22:19
Show Gist options
  • Save mathieuancelin/7241349 to your computer and use it in GitHub Desktop.
Save mathieuancelin/7241349 to your computer and use it in GitHub Desktop.
Introducing Capped buckets
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