Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Operações básicas com riak usando scala
package com.softsimples.social.persistence
import scala.collection.JavaConverters._
import com.basho.riak.client.bucket.Bucket
import org.json.JSONObject
class HashWrapper(private var bucket:Bucket) {
def name():String = bucket.getName
def keys(): Iterator[String] = bucket.keys().iterator.asScala
def store(key:String, value:String): String = {
bucket.store[String](key, value).execute()
}
def delete(key:String) = {
bucket.delete(key).execute()
}
def fetch(key:String): JSONObject = {
var retorno:JSONObject = new JSONObject()
val riakObject = bucket.fetch(key).execute()
if (riakObject != null) retorno = new JSONObject( riakObject.getValueAsString )
retorno
}
}
object HashWrapper {
def buildTableWrapper(bucket:Bucket): HashWrapper = new HashWrapper( bucket )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.