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 =>
9898 }
9999
100100 def unsubscribe (): Unit = {
101- send(" UNSUBSCRIBE" )(())
101+ val r = send(" UNSUBSCRIBE" )(())
102+ pubSub = false
103+ r
102104 }
103105
104106 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
106110 }
107111}
108112
Original file line number Diff line number Diff line change @@ -28,4 +28,34 @@ class RedisClientSpec extends FunSpec
2828 new RedisClient (" localhost" , 6379 , 1 ).toString shouldBe " localhost:6379/1"
2929 }
3030 }
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+ }
3161}
You can’t perform that action at this time.
0 commit comments