package mongo.casbah
import com.mongodb.casbah.Imports._
object Sample extends App {
val mongoClient = MongoClient()
val mongoDB = mongoClient("casbah_test")
val mongoColl = mongoClient("casbah_test")("test_data")
val newObj = MongoDBObject("foo" -> "bar", "x" -> "y", "pie" -> 3.14, "spam" -> "eggs")
val builder = MongoDBObject.newBuilder
builder += "L2P" -> "NOOB"
builder += "kek" -> "bur"
println(builder.result)
println(newObj.get("foo"))
}
sbt run
[info] Set current project to mongo casbah test (in build file:/mnt/hgfs/share/sbt-mongo/)
[info] Running mongo.casbah.Sample
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
{ "L2P" : "NOOB" , "kek" : "bur"}
bar
[success] Total time: 4 s, completed 2013/04/17 16:56:52
とりあえずセットとゲットはできてるので良しとする。
Playとの連携はまた後ほど調べる。
Redis
Ruby Diary redisインストール(CentOS 6.2)
を参考にしつつバージョンだけ変えて実行
wget http://redis.googlecode.com/files/redis-2.6.12.tar.gz
tar xzvf redis-2.6.12.tar.gz
cd redis-2.6.12.tar.gz
make
sudo make install
問題なく終了
redis-server
で起動し、
redis-cli
redis 127.0.0.1:6379>set 1 aaa
OK
redis 127.0.0.1:6379>get 1
"aaa"