Skip to content

Instantly share code, notes, and snippets.

@rjenkins
Created July 2, 2012 22:03
Show Gist options
  • Save rjenkins/3036017 to your computer and use it in GitHub Desktop.
Save rjenkins/3036017 to your computer and use it in GitHub Desktop.
AbstractRiakEntityDAO.scala
abstract class AbstractRiakEntityDAO[K, T](storageDriver: RiakStorageDriver[K,
T]) extends GenericKeyValueDAO[K, T]
with Logging with Converter[T] {
val stringIndexes = new ListBuffer[String]
val integerIndexes = new ListBuffer[String]
// Retrieve Entity by Key
def getByKey(key: K): Option[T] = {
storageDriver.getByKey(key, this)
}
// For a given key and type persist entity
def persist(key: K, t: T): T = {
storageDriver.persist(key, t, this)
}
def findFor2i(index: String, value: String): List[T] = {
storageDriver.findFor2i(index, value, this)
}
def findFor2i(index: String, value: Int): List[T] = {
storageDriver.findFor2i(index, value, this)
}
def delete(t: T) {
storageDriver.delete(t)
}
def deleteByKey(key: K) {
storageDriver.deleteByKey(key)
}
def deleteFor2i(index: String, value: String) {
storageDriver.deleteFor2i(index, value)
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment