Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/main/scala/com/redis/PubSub.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.redis

object Util {
object Break extends RuntimeException
def break { throw Break }
def whileTrue(block: => Unit) {
def break: Unit = { throw Break }
def whileTrue(block: => Unit): Unit = {
while (true)
try {
block
Expand All @@ -23,12 +23,12 @@ trait PubSub extends PubOperations { self: Redis =>

class Consumer(fn: PubSubMessage => Any) extends Runnable {

def start () {
def start (): Unit = {
val myThread = new Thread(this) ;
myThread.start() ;
}

override def run() {
override def run(): Unit = {
try {
whileTrue {
asList match {
Expand Down Expand Up @@ -62,7 +62,7 @@ trait PubSub extends PubOperations { self: Redis =>
}
}

def pSubscribe(channel: String, channels: String*)(fn: PubSubMessage => Any) {
def pSubscribe(channel: String, channels: String*)(fn: PubSubMessage => Any): Unit = {
if (pubSub) { // already pubsub ing
pSubscribeRaw(channel, channels: _*)
return
Expand All @@ -72,7 +72,7 @@ trait PubSub extends PubOperations { self: Redis =>
new Consumer(fn).start()
}

def pSubscribeRaw(channel: String, channels: String*) {
def pSubscribeRaw(channel: String, channels: String*): Unit = {
send("PSUBSCRIBE", channel :: channels.toList)(())
}

Expand All @@ -83,7 +83,7 @@ trait PubSub extends PubOperations { self: Redis =>
def pUnsubscribe(channel: String, channels: String*): Unit = {
send("PUNSUBSCRIBE", channel :: channels.toList)(())
}
def subscribe(channel: String, channels: String*)(fn: PubSubMessage => Any) {
def subscribe(channel: String, channels: String*)(fn: PubSubMessage => Any): Unit = {
if (pubSub) { // already pubsub ing
subscribeRaw(channel, channels: _*)
} else {
Expand All @@ -93,7 +93,7 @@ trait PubSub extends PubOperations { self: Redis =>
}
}

def subscribeRaw(channel: String, channels: String*) {
def subscribeRaw(channel: String, channels: String*): Unit = {
send("SUBSCRIBE", channel :: channels.toList)(())
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/com/redis/RedisClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ trait RedisCommand extends Redis with Operations
}
}

private def selectDatabase() {
private def selectDatabase(): Unit = {
if (database != 0)
select(database)
}

private def authenticate() {
private def authenticate(): Unit = {
secret.foreach(auth _)
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/redis/cluster/HashRing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ case class HashRing[T](nodes: List[T], replicas: Int) {
/*
* Removes node from the ring
*/
def removeNode(node: T) {
def removeNode(node: T): Unit = {
cluster -= node
(1 to replicas).foreach {replica =>
ring -= nodeHashFor(node, replica)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/redis/cluster/RedisCluster.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ abstract class RedisCluster(hosts: ClusterNode*) extends RedisCommand {
}

//remove a server
def removeServer(nodename: String){
def removeServer(nodename: String): Unit ={
hr.cluster.find(_.node.nodename.equals(nodename)) match {
case Some(pool) => {
hr removeNode(pool)
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/com/redis/cluster/RedisShards.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ abstract class RedisShards(val hosts: List[ClusterNode]) extends RedisCommand {
}

//remove a server
def removeServer(nodename: String){
def removeServer(nodename: String): Unit ={
if (clients.contains(nodename)) {
val pool = clients(nodename)
pool.close
Expand Down
8 changes: 4 additions & 4 deletions src/test/scala/com/redis/BlockingDequeSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ class BlockingDequeSpec extends FunSpec
val r2 = new RedisDequeClient("localhost", 6379).getDeque("btd", blocking = true, timeoutInSecs = 30)

class Foo extends Runnable {
def start () {
def start (): Unit = {
val myThread = new Thread(this) ;
myThread.start() ;
}

def run {
def run: Unit = {
val v = r1.poll
v.get should equal("foo")
r1.clear
Expand All @@ -47,12 +47,12 @@ class BlockingDequeSpec extends FunSpec
val r2 = new RedisDequeClient("localhost", 6379).getDeque("btd", blocking = true, timeoutInSecs = 30)

class Foo extends Runnable {
def start () {
def start (): Unit = {
val myThread = new Thread(this) ;
myThread.start() ;
}

def run {
def run: Unit = {
val v = r1.pollLast
v.get should equal("foo")
r1.clear
Expand Down
8 changes: 4 additions & 4 deletions src/test/scala/com/redis/ListOperationsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,12 @@ class ListOperationsSpec extends FunSpec
it("should pop blockingly") {
val r1 = new RedisClient("localhost", 6379)
class Foo extends Runnable {
def start () {
def start (): Unit = {
val myThread = new Thread(this) ;
myThread.start() ;
}

def run {
def run: Unit = {
r.brpoplpush("l1", "l2", 3) should equal(Some("a"))
r1.disconnect
r.lpop("l2") should equal(Some("a"))
Expand All @@ -383,12 +383,12 @@ class ListOperationsSpec extends FunSpec
it ("should pop in a blocking mode") {
val r1 = new RedisClient("localhost", 6379)
class Foo extends Runnable {
def start () {
def start (): Unit = {
val myThread = new Thread(this) ;
myThread.start() ;
}

def run {
def run: Unit = {
r.blpop(3, "l1", "l2") should equal(Some("l1", "a"))
r1.disconnect
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/com/redis/WatchSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class WatchSpec extends FunSpec
it("should fail a transaction if modified from another client") {
implicit val clients = new RedisClientPool("localhost", 6379)
class P1 extends Runnable {
def run() {
def run(): Unit = {
clients.withClient { client =>
client.watch("key")
client.pipeline { p =>
Expand All @@ -45,7 +45,7 @@ class WatchSpec extends FunSpec
}
}
class P2 extends Runnable {
def run() {
def run(): Unit = {
clients.withClient { client =>
Thread.sleep(10)
client.set("key", "anshin")
Expand Down