templates.scala.client.txt Maven / Gradle / Ivy
package com.twitter.finagle.redis
import com.google.common.base.Charsets
import com.twitter.finagle.Service
import com.twitter.finagle.builder.ClientBuilder
import com.twitter.util.Future
import org.jboss.netty.buffer.ChannelBuffers
import redis._
import redis.netty._
import scala.collection.mutable.ArrayBuffer
object RedisClient {
/**
* Construct a client from a single host.
* @param host a String of host:port combination.
*/
def apply(host: String): RedisClient = RedisClient(
ClientBuilder()
.hosts(host)
.hostConnectionLimit(1)
.codec(new RedisCodecFactory)
.build())
/**
* 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()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy