@@ -30,10 +30,10 @@ trait Redis extends IO with Protocol {
30
30
result
31
31
} catch {
32
32
case e : RedisConnectionException =>
33
- if (reconnect ) send(command, args)(result)
33
+ if (disconnect ) send(command, args)(result)
34
34
else throw e
35
35
case e : SocketException =>
36
- if (reconnect ) send(command, args)(result)
36
+ if (disconnect ) send(command, args)(result)
37
37
else throw e
38
38
}
39
39
@@ -42,10 +42,10 @@ trait Redis extends IO with Protocol {
42
42
result
43
43
} catch {
44
44
case e : RedisConnectionException =>
45
- if (reconnect ) send(command)(result)
45
+ if (disconnect ) send(command)(result)
46
46
else throw e
47
47
case e : SocketException =>
48
- if (reconnect ) send(command)(result)
48
+ if (disconnect ) send(command)(result)
49
49
else throw e
50
50
}
51
51
@@ -54,11 +54,6 @@ trait Redis extends IO with Protocol {
54
54
protected def flattenPairs (in : Iterable [Product2 [Any , Any ]]): List [Any ] =
55
55
in.iterator.flatMap(x => Iterator (x._1, x._2)).toList
56
56
57
- def reconnect : Boolean = {
58
- disconnect && initialize
59
- }
60
-
61
- protected def initialize : Boolean
62
57
}
63
58
64
59
trait RedisCommand extends Redis
@@ -78,16 +73,11 @@ trait RedisCommand extends Redis
78
73
val database : Int = 0
79
74
val secret : Option [Any ] = None
80
75
81
- override def initialize : Boolean = {
82
- if (connect) {
83
- secret.foreach {s =>
84
- auth(s)
85
- }
86
- selectDatabase()
87
- true
88
- } else {
89
- false
76
+ override def onConnect : Unit = {
77
+ secret.foreach {s =>
78
+ auth(s)
90
79
}
80
+ selectDatabase()
91
81
}
92
82
93
83
private def selectDatabase (): Unit = {
@@ -106,8 +96,6 @@ class RedisClient(override val host: String, override val port: Int,
106
96
override val database : Int = 0 , override val secret : Option [Any ] = None , override val timeout : Int = 0 )
107
97
extends RedisCommand with PubSub {
108
98
109
- initialize
110
-
111
99
def this () = this (" localhost" , 6379 )
112
100
def this (connectionUri : java.net.URI ) = this (
113
101
host = connectionUri.getHost,
@@ -217,13 +205,12 @@ class RedisClient(override val host: String, override val port: Int,
217
205
// TODO: Find a better abstraction
218
206
override def connected = parent.connected
219
207
override def connect = parent.connect
220
- override def reconnect = parent.reconnect
221
208
override def disconnect = parent.disconnect
222
209
override def clearFd = parent.clearFd
223
210
override def write (data : Array [Byte ]) = parent.write(data)
224
211
override def readLine = parent.readLine
225
212
override def readCounted (count : Int ) = parent.readCounted(count)
226
- override def initialize = parent.initialize
213
+ override def onConnect () = parent.onConnect()
227
214
228
215
override def close (): Unit = parent.close()
229
216
}
0 commit comments