From ae217524f8571168ea93383fab7e540c387cc1e0 Mon Sep 17 00:00:00 2001 From: mori_takuma Date: Mon, 28 Sep 2015 14:49:17 +0900 Subject: [PATCH 1/6] modified: pom.xml modified: src/main/scala/sedis.scala --- pom2.10.xml | 89 ----------------------------------------------------- 1 file changed, 89 deletions(-) delete mode 100644 pom2.10.xml diff --git a/pom2.10.xml b/pom2.10.xml deleted file mode 100644 index 1cae5b5..0000000 --- a/pom2.10.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - 2.10.0 - - -4.0.0 -org.sedis -sedis_2.10 -jar -1.2.2 -Sedis for Scala ${scala.version} - - - - redis.clients - jedis - 2.4.2 - jar - compile - - - org.scalatest - scalatest_${scala.version} - 1.8 - test - - - - - - repo.codahale.com - http://repo.codahale.com - - - - - - - net.alchim31.maven - scala-maven-plugin - 3.1.1 - - - - scala-compile-first - process-resources - - add-source - compile - - - - - - -Xmx1g - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.5.1 - - 1.7 - 1.7 - UTF-8 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.8.1 - - false - false - -Xmx1024m - - **/*Spec.java - - - **/*Test.java - - - - - - - From e7eb56ec1e66cd2e90a4ee40cf70fd00b15f8812 Mon Sep 17 00:00:00 2001 From: mori_takuma Date: Mon, 28 Sep 2015 14:53:39 +0900 Subject: [PATCH 2/6] Revert " modified: pom.xml" This reverts commit ae217524f8571168ea93383fab7e540c387cc1e0. --- pom2.10.xml | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 pom2.10.xml diff --git a/pom2.10.xml b/pom2.10.xml new file mode 100644 index 0000000..1cae5b5 --- /dev/null +++ b/pom2.10.xml @@ -0,0 +1,89 @@ + + + 2.10.0 + + +4.0.0 +org.sedis +sedis_2.10 +jar +1.2.2 +Sedis for Scala ${scala.version} + + + + redis.clients + jedis + 2.4.2 + jar + compile + + + org.scalatest + scalatest_${scala.version} + 1.8 + test + + + + + + repo.codahale.com + http://repo.codahale.com + + + + + + + net.alchim31.maven + scala-maven-plugin + 3.1.1 + + + + scala-compile-first + process-resources + + add-source + compile + + + + + + -Xmx1g + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + 1.7 + 1.7 + UTF-8 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.8.1 + + false + false + -Xmx1024m + + **/*Spec.java + + + **/*Test.java + + + + + + + From 517cde040a3fc106e175a675532ce8901a127a29 Mon Sep 17 00:00:00 2001 From: mori_takuma Date: Mon, 28 Sep 2015 14:55:49 +0900 Subject: [PATCH 3/6] jedis version up & replace deplicated method --- pom.xml | 2 +- src/main/scala/sedis.scala | 46 ++++++++++---------------------------- 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/pom.xml b/pom.xml index 5898a94..f6c7f6d 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ redis.clients jedis - 2.4.2 + 2.7.3 jar compile diff --git a/src/main/scala/sedis.scala b/src/main/scala/sedis.scala index b0377bf..02b4e76 100644 --- a/src/main/scala/sedis.scala +++ b/src/main/scala/sedis.scala @@ -91,46 +91,24 @@ trait Dress { } object Dress extends Dress +abstract class AbstractPool { + def using[A <% java.io.Closeable, T](s: A)(f: A => T): T = try f(s) finally s.close() -class Pool(val underlying: JedisPool) { +} - def withClient[T](body: Dress.Wrap => T): T = { - val jedis: Jedis = underlying.getResource - try { - body(Dress.up(jedis)) - } finally { - underlying.returnResourceObject(jedis) - } - } - def withJedisClient[T](body: Jedis => T): T = { - val jedis: Jedis = underlying.getResource - try { - body(jedis) - } finally { - underlying.returnResourceObject(jedis) - } - } +class Pool(val jedisPool: JedisPool) extends AbstoractPool { + + def withClient[T](body: Dress.Wrap => T): T = using(Dress.up(jedisPool.getResource))(body) + + def withJedisClient[T](body: Jedis => T): T = using(jedisPool.getResource)(body) } -class SentinelPool(val underlying: JedisSentinelPool) { +class SentinelPool(val jedisSentinelPool: JedisSentinelPool) extends AbstractPool { - def withClient[T](body: Dress.Wrap => T): T = { - val jedis: Jedis = underlying.getResource - try { - body(Dress.up(jedis)) - } finally { - underlying.returnResourceObject(jedis) - } - } - def withJedisClient[T](body: Jedis => T): T = { - val jedis: Jedis = underlying.getResource - try { - body(jedis) - } finally { - underlying.returnResourceObject(jedis) - } - } + def withClient[T](body: Dress.Wrap => T): T = using(Dress.up(jedisSentinelPool.getResource))(body) + + def withJedisClient[T](body: Jedis => T): T = using(jedisSentinelPool.getResource)(body) } From 31cf5b47ac2c14a6fd1eb3a9f405c9a3faedbe3c Mon Sep 17 00:00:00 2001 From: mori_takuma Date: Mon, 28 Sep 2015 14:59:36 +0900 Subject: [PATCH 4/6] refactor code : checking null --- src/main/scala/sedis.scala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/scala/sedis.scala b/src/main/scala/sedis.scala index 02b4e76..d4683ba 100644 --- a/src/main/scala/sedis.scala +++ b/src/main/scala/sedis.scala @@ -58,8 +58,7 @@ trait Dress { } def get(k: String): Option[String] = { - val f = j.get(k) - if (f == null) None else Some(f) + Option(j.get(k)) } def lrange(key: String, start: Long, end: Long): List[String] = { j.lrange(key,start,end).asScala.toList @@ -97,7 +96,7 @@ abstract class AbstractPool { } -class Pool(val jedisPool: JedisPool) extends AbstoractPool { +class Pool(val jedisPool: JedisPool) extends AbstractPool { def withClient[T](body: Dress.Wrap => T): T = using(Dress.up(jedisPool.getResource))(body) From e4463e36a25a6c4f5669600a8b942f1e4ecbb696 Mon Sep 17 00:00:00 2001 From: mori_takuma Date: Wed, 13 Apr 2016 20:55:59 +0900 Subject: [PATCH 5/6] squash pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f6c7f6d..5898a94 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ redis.clients jedis - 2.7.3 + 2.4.2 jar compile From 1b78f4a998cfd8aee4ea95a7645d3372519b5193 Mon Sep 17 00:00:00 2001 From: mori_takuma Date: Tue, 14 Jun 2016 18:04:11 +0900 Subject: [PATCH 6/6] rm unrelated fix --- src/main/scala/sedis.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/scala/sedis.scala b/src/main/scala/sedis.scala index 1828823..c24c71a 100644 --- a/src/main/scala/sedis.scala +++ b/src/main/scala/sedis.scala @@ -62,7 +62,8 @@ trait Dress { } def get(k: String): Option[String] = { - Option(j.get(k)) + val f = j.get(k) + if (f == null) None else Some(f) } def lrange(key: String, start: Long, end: Long): List[String] = { j.lrange(key,start,end).asScala.toList