scala-cassandra -


Apache
跨平台
Scala

软件简介

scala-cassandra 实现了对 Cassandra
DataStax Java 驱动程序的 Scala 封装。

示例代码:

class ScalaCassandraSpec extends Specification {

    CQL.init()
    CQL.startup("MetaStore")
    Meta.createTable()

    "Meta objects" should {
      "be able to store & retrieve their binary state" in {

      //we use a Thrift object here for portability of the data stored
      val tMeta = new TMeta()

      //setting up some randomness so we can confirm what we are writing is what we get back
      val metaUUID = UUID.randomUUID()
      val dataum = Random.alphanumeric.take(1000000).mkString

      tMeta.setId(metaUUID.toString)
      tMeta.setDatum(dataum)

      Meta.save(tMeta) //Saved to C*

      val someNewTMeta = Meta(metaUUID)
      someNewTMeta.getId() must_== metaUUID.toString

      someNewTMeta.getDatum() must_== dataum
      }
    }
}