scala-redis
scala-redis copied to clipboard
Does disconnect really close connection ?
I am having trouble trying to disconnect from Redis. Here is what I am doing
scala> import com.redis._
import com.redis._
scala> val r = new RedisClient("localhost", 4518)
r: com.redis.RedisClient = localhost:4518
scala> r.get("test")
res5: Option[String] = None
scala> r.set("test", "value")
res6: Boolean = true
scala> r.disconnect
res8: Boolean = true
scala> r.get("test")
res9: Option[String] = Some(value)
Even after the disconnect, the client still works ?
actually, it willl close the socket, but when you issue another redis command, it will try to reconnect.
`def send[A](command: String, args: Seq[Any])(result: => A)(implicit format: Format): A = try { write(Commands.multiBulk(command.getBytes("UTF-8") +: (args map (format.apply)))) result } catch { case e: RedisConnectionException => if (reconnect) send(command, args)(result) else throw e case e: SocketException => if (reconnect) send(command, args)(result) else throw e }
def send[A](command: String)(result: => A): A = try { write(Commands.multiBulk(List(command.getBytes("UTF-8")))) result } catch { case e: RedisConnectionException => if (reconnect) send(command)(result) else throw e case e: SocketException => if (reconnect) send(command)(result) else throw e }`
So, how to disable reconnect option or can I force disconnect?