templates.scala.service.txt Maven / Gradle / Ivy
package com.twitter.finagle.redisservice
import com.google.common.base.Charsets
import com.twitter.finagle.Service
import com.twitter.util.Future
import redis._
import redis.reply._
object RedisClient {
/**
* Construct a client from a single host.
* @param host a String of host:port combination.
*/
def apply(host: String, port: Int): RedisClient = RedisClient(new RedisServiceFactory(host, port).apply().get())
/**
* Construct a client from a single Service.
*/
def apply(service: Service[Command, Reply[_]]): RedisClient = new RedisClient(service)
{{#commands}}
val {{name}} = "{{name}}"
val {{name}}_BYTES = {{name}}.getBytes(Charsets.UTF_8)
{{/commands}}
}
case class RedisException(message:String) extends RuntimeException(message)
class RedisClient(service: Service[Command, Reply[_]]) {
{{#commands}}
{{>method}}
{{/commands}}
def release() {
service.release()
}
}