Skip to content

Commit a7e0d4c

Browse files
author
Alexandre Curreli
committed
Added documentation + do not import AnyWriter by default
1 parent 5e43c0d commit a7e0d4c

File tree

5 files changed

+34
-10
lines changed

5 files changed

+34
-10
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ organization := "com.livestream"
66

77
name := "scredis"
88

9-
version := "2.0.0-RC1"
9+
version := "2.0.0"
1010

1111
scalaVersion := "2.11.2"
1212

src/main/scala/scredis/commands/TransactionCommands.scala

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,36 @@ trait TransactionCommands {
3636
*/
3737
def unwatch(): Future[Unit] = send(Unwatch())
3838

39-
def inTransaction(f: TransactionBuilder => Any): Future[IndexedSeq[Try[Any]]] = {
39+
/**
40+
* Executes a transaction and returns the results of all queued commands.
41+
*
42+
* @param build the transaction block
43+
* @return vector containing the results of all queued commands
44+
*
45+
* @since 1.2.0
46+
*/
47+
def inTransaction(build: TransactionBuilder => Any): Future[Vector[Try[Any]]] = {
4048
val builder = new TransactionBuilder()
4149
try {
42-
f(builder)
50+
build(builder)
4351
send(builder.result())
4452
} catch {
4553
case e: Throwable => Future.failed(RedisTransactionBuilderException(cause = e))
4654
}
4755
}
4856

49-
def withTransaction[A](f: TransactionBuilder => A): A = {
57+
/**
58+
* Executes a transaction and returns whatever the transaction block returns.
59+
*
60+
* @param build the transaction block
61+
* @return whatever 'build' returns
62+
*
63+
* @since 1.2.0
64+
*/
65+
def withTransaction[A](build: TransactionBuilder => A): A = {
5066
val builder = new TransactionBuilder()
5167
try {
52-
val result = f(builder)
68+
val result = build(builder)
5369
send(builder.result())
5470
result
5571
} catch {

src/main/scala/scredis/package.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ package object scredis {
1313
}
1414

1515
implicit val stringReader: Reader[String] = UTF8StringReader
16-
implicit val anyWriter: Writer[Any] = AnyWriter
16+
17+
implicit val bytesWriter: Writer[Array[Byte]] = BytesWriter
18+
implicit val stringWriter: Writer[String] = UTF8StringWriter
19+
implicit val booleanWriter: Writer[Boolean] = BooleanWriter
20+
implicit val shortWriter: Writer[Short] = ShortWriter
21+
implicit val intWriter: Writer[Int] = IntWriter
22+
implicit val longWriter: Writer[Long] = LongWriter
23+
implicit val floatWriter: Writer[Float] = FloatWriter
24+
implicit val doubleWriter: Writer[Double] = DoubleWriter
1725

1826
implicit def shortToScoreValue(value: Short): Score.Value = Score.Value(value)
1927
implicit def intToScoreValue(value: Int): Score.Value = Score.Value(value)

src/test/scala/scredis/commands/SetCommandsSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,18 +440,18 @@ class SetCommandsSpec extends WordSpec
440440

441441
val member1 = client.sPop("SET").futureValue
442442
member1 should contain oneOf ("A", "B", "C")
443-
client.sIsMember("SET", member1).futureValue should be (false)
443+
client.sIsMember("SET", member1.get).futureValue should be (false)
444444

445445
val member2 = client.sPop("SET").futureValue
446446
member2 should contain oneOf ("A", "B", "C")
447447
member2 should not contain (member1)
448-
client.sIsMember("SET", member2).futureValue should be (false)
448+
client.sIsMember("SET", member2.get).futureValue should be (false)
449449

450450
val member3 = client.sPop("SET").futureValue
451451
member3 should contain oneOf ("A", "B", "C")
452452
member3 should not contain (member1)
453453
member3 should not contain (member2)
454-
client.sIsMember("SET", member3).futureValue should be (false)
454+
client.sIsMember("SET", member3.get).futureValue should be (false)
455455

456456
client.sPop("SET").futureValue should be (empty)
457457
}

src/test/scala/scredis/serialization/SerializationSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SerializationSpec extends WordSpec
3434
client.set[Boolean]("boolean", true).futureValue should be (true)
3535
client.set[Int]("number", 5).futureValue should be (true)
3636
client.set[Double]("decimal", 5.5).futureValue should be (true)
37-
client.rPush[Any]("list", "1", 2, 3, "4", "5").futureValue should be (5)
37+
client.rPush[Any]("list", "1", 2, 3, "4", "5")(AnyWriter).futureValue should be (5)
3838
}
3939
}
4040
}

0 commit comments

Comments
 (0)