Created
October 14, 2011 16:23
-
-
Save agnaldo4j/1287575 to your computer and use it in GitHub Desktop.
Operações básicas com riak usando scala
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
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