File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -98,11 +98,15 @@ trait PubSub extends PubOperations { self: Redis =>
98
98
}
99
99
100
100
def unsubscribe (): Unit = {
101
- send(" UNSUBSCRIBE" )(())
101
+ val r = send(" UNSUBSCRIBE" )(())
102
+ pubSub = false
103
+ r
102
104
}
103
105
104
106
def unsubscribe (channel : String , channels : String * ): Unit = {
105
- send(" UNSUBSCRIBE" , channel :: channels.toList)(())
107
+ val r = send(" UNSUBSCRIBE" , channel :: channels.toList)(())
108
+ pubSub = false
109
+ r
106
110
}
107
111
}
108
112
Original file line number Diff line number Diff line change @@ -28,4 +28,34 @@ class RedisClientSpec extends FunSpec
28
28
new RedisClient (" localhost" , 6379 , 1 ).toString shouldBe " localhost:6379/1"
29
29
}
30
30
}
31
+
32
+ describe(" test subscribe" ) {
33
+ val r = new RedisClient (" localhost" , 6379 )
34
+
35
+ println(r.get(" vvl:qm" ))
36
+
37
+ r.subscribe(" vvl.qm" ) { m =>
38
+ println(m)
39
+ }
40
+
41
+ Thread .sleep(3000 )
42
+
43
+ r.unsubscribe(" vvl.qm" )
44
+
45
+ Thread .sleep(3000 )
46
+
47
+ println(r.get(" vvl:qm" ))
48
+
49
+ r.subscribe(" vvl.qm" ) { m =>
50
+ println(m)
51
+ }
52
+
53
+ Thread .sleep(3000 )
54
+
55
+ r.unsubscribe(" vvl.qm" )
56
+
57
+ Thread .sleep(3000 )
58
+
59
+ r.get(" vvl:qm" )
60
+ }
31
61
}
You can’t perform that action at this time.
0 commit comments