From 0856f7da66d8df16b4712f0d93123d2b08deea5c Mon Sep 17 00:00:00 2001 From: Ahsan Rabbani Date: Sun, 5 Jan 2014 02:14:03 -0500 Subject: [PATCH 1/8] added support for JedisSentinelPool --- redis/project/Build.scala | 7 +- .../com/typesafe/plugin/RedisPlugin.scala | 95 ++++++++++++------- 2 files changed, 67 insertions(+), 35 deletions(-) diff --git a/redis/project/Build.scala b/redis/project/Build.scala index 79527b3..95cfc83 100644 --- a/redis/project/Build.scala +++ b/redis/project/Build.scala @@ -9,8 +9,10 @@ object MinimalBuild extends Build { lazy val typesafe = "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/" lazy val repo = if (buildVersion.endsWith("SNAPSHOT")) typesafeSnapshot else typesafe lazy val pk11 = "pk11 repo" at "http://pk11-scratch.googlecode.com/svn/trunk" + // for sedis 1.1.9 which hasn't been merged to master and doesn't exist in any repo yet + lazy val mavenLocal = "Maven Local" at Path.userHome.asFile.toURI.toURL + ".m2/repository" lazy val root = Project(id = "play-plugins-redis", base = file("."), settings = Project.defaultSettings).settings( - version := "2.2.0", + version := "2.2.1", scalaVersion := "2.10.2", publishTo <<= (version) { version: String => val nexus = "https://private-repo.typesafe.com/typesafe/" @@ -20,10 +22,11 @@ object MinimalBuild extends Build { organization := "com.typesafe", resolvers += repo, resolvers += pk11, + resolvers += mavenLocal, javacOptions += "-Xlint:unchecked", libraryDependencies += "biz.source_code" % "base64coder" % "2010-12-19", libraryDependencies += "com.typesafe" %% "play-plugins-util" % buildVersion, libraryDependencies += "com.typesafe.play" %% "play-cache" % buildVersion % "provided", - libraryDependencies += "org.sedis" % "sedis_2.10.0" % "1.1.1" + libraryDependencies += "org.sedis" % "sedis_2.10.0" % "1.1.9" ) } diff --git a/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala b/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala index 9d9a718..412fd06 100644 --- a/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala +++ b/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala @@ -4,13 +4,12 @@ import play.api._ import org.sedis._ import redis.clients.jedis._ import play.api.cache._ -import java.util._ import java.io._ import java.net.URI import biz.source_code.base64Coder._ import org.apache.commons.lang3.builder._ -import org.apache.commons.pool.impl.GenericObjectPool import play.api.mvc.Result +import scala.collection.JavaConversions._ /** * provides a redis client and a CachePlugin implementation @@ -37,43 +36,56 @@ class RedisPlugin(app: Application) extends CachePlugin { private lazy val timeout = app.configuration.getInt("redis.timeout") .getOrElse(2000) + private lazy val sentinelMode = app.configuration.getBoolean("redis.sentinel.mode") + .getOrElse(false) + + private lazy val sentinelHosts : java.util.List[String] = app.configuration.getStringList("redis.sentinel.hosts") + .getOrElse(seqAsJavaList(List("localhost:6379"))) + + private lazy val masterName = app.configuration.getString("redis.master.name") + .getOrElse("mymaster") /** * provides access to the underlying jedis Pool */ - lazy val jedisPool = { + lazy val jedisPool : Either[JedisPool, JedisSentinelPool] = { val poolConfig = createPoolConfig(app) - Logger.info(s"Redis Plugin enabled. Connecting to Redis on ${host}:${port} with timeout ${timeout}.") - Logger.info("Redis Plugin pool configuration: " + new ReflectionToStringBuilder(poolConfig).toString()) - new JedisPool(poolConfig, host, port, timeout, password) + + if (sentinelMode) { + Logger.info(s"Redis Plugin enabled. Connecting to Redis sentinels ${sentinelHosts} with timeout ${timeout}.") + Logger.info("Redis Plugin pool configuration: " + new ReflectionToStringBuilder(poolConfig).toString()) + val sentinelSet = new java.util.HashSet[String]() + sentinelSet.addAll(sentinelHosts) + Right(new JedisSentinelPool(masterName, sentinelSet, poolConfig, timeout, password)) + } else { + Logger.info(s"Redis Plugin enabled. Connecting to Redis on ${host}:${port} with timeout ${timeout}.") + Logger.info("Redis Plugin pool configuration: " + new ReflectionToStringBuilder(poolConfig).toString()) + Left(new JedisPool(poolConfig, host, port, timeout, password)) + } } /** * provides access to the sedis Pool */ - lazy val sedisPool = new Pool(jedisPool) + lazy val sedisPool : Either[Pool, SentinelPool] = jedisPool match { + case Left(pool) => Left(new Pool(pool)) + case Right(pool) => Right(new SentinelPool(pool)) + } private def createPoolConfig(app: Application) : JedisPoolConfig = { val poolConfig : JedisPoolConfig = new JedisPoolConfig() - app.configuration.getInt("redis.pool.maxIdle").map { poolConfig.maxIdle = _ } - app.configuration.getInt("redis.pool.minIdle").map { poolConfig.minIdle = _ } - app.configuration.getInt("redis.pool.maxActive").map { poolConfig.maxActive = _ } - app.configuration.getInt("redis.pool.maxWait").map { poolConfig.maxWait = _ } - app.configuration.getBoolean("redis.pool.testOnBorrow").map { poolConfig.testOnBorrow = _ } - app.configuration.getBoolean("redis.pool.testOnReturn").map { poolConfig.testOnReturn = _ } - app.configuration.getBoolean("redis.pool.testWhileIdle").map { poolConfig.testWhileIdle = _ } - app.configuration.getLong("redis.pool.timeBetweenEvictionRunsMillis").map { poolConfig.timeBetweenEvictionRunsMillis = _ } - app.configuration.getInt("redis.pool.numTestsPerEvictionRun").map { poolConfig.numTestsPerEvictionRun = _ } - app.configuration.getLong("redis.pool.minEvictableIdleTimeMillis").map { poolConfig.minEvictableIdleTimeMillis = _ } - app.configuration.getLong("redis.pool.softMinEvictableIdleTimeMillis").map { poolConfig.softMinEvictableIdleTimeMillis = _ } - app.configuration.getBoolean("redis.pool.lifo").map { poolConfig.lifo = _ } - app.configuration.getString("redis.pool.whenExhaustedAction").map { setting => - poolConfig.whenExhaustedAction = setting match { - case "fail" | "0" => GenericObjectPool.WHEN_EXHAUSTED_FAIL - case "block" | "1" => GenericObjectPool.WHEN_EXHAUSTED_BLOCK - case "grow" | "2" => GenericObjectPool.WHEN_EXHAUSTED_FAIL - } - } + app.configuration.getInt("redis.pool.maxIdle").map { poolConfig.setMaxIdle(_) } + app.configuration.getInt("redis.pool.minIdle").map { poolConfig.setMinIdle(_) } + app.configuration.getInt("redis.pool.maxTotal").map { poolConfig.setMaxTotal(_) } + app.configuration.getBoolean("redis.pool.testOnBorrow").map { poolConfig.setTestOnBorrow(_) } + app.configuration.getBoolean("redis.pool.testOnReturn").map { poolConfig.setTestOnReturn(_) } + app.configuration.getBoolean("redis.pool.testWhileIdle").map { poolConfig.setTestWhileIdle(_) } + app.configuration.getLong("redis.pool.timeBetweenEvictionRunsMillis").map { poolConfig.setTimeBetweenEvictionRunsMillis(_) } + app.configuration.getInt("redis.pool.numTestsPerEvictionRun").map { poolConfig.setNumTestsPerEvictionRun(_) } + app.configuration.getLong("redis.pool.minEvictableIdleTimeMillis").map { poolConfig.setMinEvictableIdleTimeMillis(_) } + app.configuration.getLong("redis.pool.softMinEvictableIdleTimeMillis").map { poolConfig.setSoftMinEvictableIdleTimeMillis(_) } + app.configuration.getBoolean("redis.pool.lifo").map { poolConfig.setLifo(_) } + app.configuration.getBoolean("redis.pool.blockWhenExhausted").map { poolConfig.setBlockWhenExhausted(_) } poolConfig } @@ -82,7 +94,10 @@ class RedisPlugin(app: Application) extends CachePlugin { } override def onStop() { - jedisPool.destroy() + jedisPool match { + case Left(pool) => pool.destroy() + case Right(pool) => pool.destroy() + } } override lazy val enabled = { @@ -132,10 +147,10 @@ class RedisPlugin(app: Application) extends CachePlugin { } val redisV = prefix + "-" + new String( Base64Coder.encode( baos.toByteArray() ) ) Logger.trace(s"Setting key ${key} to ${redisV}") - - sedisPool.withJedisClient { client => - client.set(key,redisV) - if (expiration != 0) client.expire(key,expiration) + + sedisPool match { + case Left(pool) => pool.withJedisClient { client => setValue(client, key, redisV, expiration) } + case Right(pool) => pool.withJedisClient { client => setValue(client, key, redisV, expiration) } } } catch {case ex: IOException => Logger.warn("could not serialize key:"+ key + " and value:"+ value.toString + " ex:"+ex.toString) @@ -145,7 +160,18 @@ class RedisPlugin(app: Application) extends CachePlugin { } } - def remove(key: String): Unit = sedisPool.withJedisClient { client => client.del(key) } + + private def setValue(client: Jedis, key: String, value: String, expiration: Int) { + client.set(key, value) + if (expiration != 0) client.expire(key, expiration) + } + + def remove(key: String): Unit = { + sedisPool match { + case Left(pool) => pool.withJedisClient { client => client.del(key) } + case Right(pool) => pool.withJedisClient { client => client.del(key) } + } + } class ClassLoaderObjectInputStream(stream:InputStream) extends ObjectInputStream(stream) { override protected def resolveClass(desc: ObjectStreamClass) = { @@ -159,7 +185,10 @@ class RedisPlugin(app: Application) extends CachePlugin { var ois: ObjectInputStream = null var dis: DataInputStream = null try { - val rawData = sedisPool.withJedisClient { client => client.get(key) } + val rawData = sedisPool match { + case Left(pool) => pool.withJedisClient { client => client.get(key) } + case Right(pool) => pool.withJedisClient { client => client.get(key) } + } rawData match { case null => None From 447092db6c0053cb7a5cdc4edc3db4fefb27aa87 Mon Sep 17 00:00:00 2001 From: Ahsan Rabbani Date: Sun, 5 Jan 2014 02:19:20 -0500 Subject: [PATCH 2/8] added support for JedisSentinelPool --- redis/project/Build.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis/project/Build.scala b/redis/project/Build.scala index 95cfc83..8abc829 100644 --- a/redis/project/Build.scala +++ b/redis/project/Build.scala @@ -3,7 +3,7 @@ import Keys._ object MinimalBuild extends Build { - lazy val buildVersion = "2.2.0" + lazy val buildVersion = "2.2.1" lazy val typesafeSnapshot = "Typesafe Snapshots Repository" at "http://repo.typesafe.com/typesafe/snapshots/" lazy val typesafe = "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/" From 589049528c37bc35d88454d721efa18f3f543629 Mon Sep 17 00:00:00 2001 From: Ahsan Rabbani Date: Sun, 5 Jan 2014 11:44:39 -0500 Subject: [PATCH 3/8] added support for JedisSentinelPool --- redis/project/Build.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis/project/Build.scala b/redis/project/Build.scala index 8abc829..95cfc83 100644 --- a/redis/project/Build.scala +++ b/redis/project/Build.scala @@ -3,7 +3,7 @@ import Keys._ object MinimalBuild extends Build { - lazy val buildVersion = "2.2.1" + lazy val buildVersion = "2.2.0" lazy val typesafeSnapshot = "Typesafe Snapshots Repository" at "http://repo.typesafe.com/typesafe/snapshots/" lazy val typesafe = "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/" From 0dcd166bbea9c292a10cfcc6b4f9f3ea8d48ebac Mon Sep 17 00:00:00 2001 From: Ahsan Rabbani Date: Sun, 5 Jan 2014 15:33:46 -0500 Subject: [PATCH 4/8] added support for JedisSentinelPool --- .../com/typesafe/plugin/RedisPlugin.scala | 73 +++++++++++-------- 1 file changed, 44 insertions(+), 29 deletions(-) diff --git a/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala b/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala index 412fd06..61e8bac 100644 --- a/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala +++ b/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala @@ -48,30 +48,35 @@ class RedisPlugin(app: Application) extends CachePlugin { /** * provides access to the underlying jedis Pool */ - lazy val jedisPool : Either[JedisPool, JedisSentinelPool] = { + lazy val jedisPool = { val poolConfig = createPoolConfig(app) - - if (sentinelMode) { - Logger.info(s"Redis Plugin enabled. Connecting to Redis sentinels ${sentinelHosts} with timeout ${timeout}.") - Logger.info("Redis Plugin pool configuration: " + new ReflectionToStringBuilder(poolConfig).toString()) - val sentinelSet = new java.util.HashSet[String]() - sentinelSet.addAll(sentinelHosts) - Right(new JedisSentinelPool(masterName, sentinelSet, poolConfig, timeout, password)) - } else { - Logger.info(s"Redis Plugin enabled. Connecting to Redis on ${host}:${port} with timeout ${timeout}.") - Logger.info("Redis Plugin pool configuration: " + new ReflectionToStringBuilder(poolConfig).toString()) - Left(new JedisPool(poolConfig, host, port, timeout, password)) - } + Logger.info(s"Redis Plugin enabled. Connecting to Redis on ${host}:${port} with timeout ${timeout}.") + Logger.info("Redis Plugin pool configuration: " + new ReflectionToStringBuilder(poolConfig).toString()) + new JedisPool(poolConfig, host, port, timeout, password) } /** * provides access to the sedis Pool */ - lazy val sedisPool : Either[Pool, SentinelPool] = jedisPool match { - case Left(pool) => Left(new Pool(pool)) - case Right(pool) => Right(new SentinelPool(pool)) + lazy val sedisPool = new Pool(jedisPool) + + /** + * provides access to the underlying jedis sentinel Pool + */ + lazy val jedisSentinelPool = { + val poolConfig = createPoolConfig(app) + Logger.info(s"Redis Plugin enabled. Connecting to Redis sentinels ${sentinelHosts} with timeout ${timeout}.") + Logger.info("Redis Plugin pool configuration: " + new ReflectionToStringBuilder(poolConfig).toString()) + val sentinelSet = new java.util.HashSet[String]() + sentinelSet.addAll(sentinelHosts) + new JedisSentinelPool(masterName, sentinelSet, poolConfig, timeout, password) } + /** + * provides access to the sedis sentinel Pool + */ + lazy val sedisSentinelPool = new SentinelPool(jedisSentinelPool) + private def createPoolConfig(app: Application) : JedisPoolConfig = { val poolConfig : JedisPoolConfig = new JedisPoolConfig() app.configuration.getInt("redis.pool.maxIdle").map { poolConfig.setMaxIdle(_) } @@ -90,13 +95,18 @@ class RedisPlugin(app: Application) extends CachePlugin { } override def onStart() { - sedisPool + if (sentinelMode) { + sedisSentinelPool + } else { + sedisPool + } } override def onStop() { - jedisPool match { - case Left(pool) => pool.destroy() - case Right(pool) => pool.destroy() + if (sentinelMode) { + jedisSentinelPool.destroy() + } else { + jedisPool.destroy() } } @@ -148,9 +158,10 @@ class RedisPlugin(app: Application) extends CachePlugin { val redisV = prefix + "-" + new String( Base64Coder.encode( baos.toByteArray() ) ) Logger.trace(s"Setting key ${key} to ${redisV}") - sedisPool match { - case Left(pool) => pool.withJedisClient { client => setValue(client, key, redisV, expiration) } - case Right(pool) => pool.withJedisClient { client => setValue(client, key, redisV, expiration) } + if (sentinelMode) { + sedisSentinelPool.withJedisClient { client => setValue(client, key, redisV, expiration) } + } else { + sedisPool.withJedisClient { client => setValue(client, key, redisV, expiration) } } } catch {case ex: IOException => Logger.warn("could not serialize key:"+ key + " and value:"+ value.toString + " ex:"+ex.toString) @@ -167,9 +178,10 @@ class RedisPlugin(app: Application) extends CachePlugin { } def remove(key: String): Unit = { - sedisPool match { - case Left(pool) => pool.withJedisClient { client => client.del(key) } - case Right(pool) => pool.withJedisClient { client => client.del(key) } + if (sentinelMode) { + sedisSentinelPool.withJedisClient { client => client.del(key) } + } else { + sedisPool.withJedisClient { client => client.del(key) } } } @@ -185,9 +197,12 @@ class RedisPlugin(app: Application) extends CachePlugin { var ois: ObjectInputStream = null var dis: DataInputStream = null try { - val rawData = sedisPool match { - case Left(pool) => pool.withJedisClient { client => client.get(key) } - case Right(pool) => pool.withJedisClient { client => client.get(key) } + val rawData = { + if (sentinelMode) { + sedisSentinelPool.withJedisClient { client => client.get(key) } + } else { + sedisPool.withJedisClient { client => client.get(key) } + } } rawData match { case null => From 150d7afa6a3abef584d3e91cc227ae540f7c2cee Mon Sep 17 00:00:00 2001 From: Ahsan Rabbani Date: Sun, 5 Jan 2014 17:25:29 -0500 Subject: [PATCH 5/8] added support for JedisSentinelPool --- redis/project/Build.scala | 5 +++-- redis/sample/app/Global.java | 2 ++ redis/sample/app/controllers/Application.java | 2 ++ redis/sample/conf/application.conf | 6 ++++++ redis/sample/project/Build.scala | 2 +- .../com/typesafe/plugin/RedisPlugin.scala | 19 +++++++++++++------ 6 files changed, 27 insertions(+), 9 deletions(-) diff --git a/redis/project/Build.scala b/redis/project/Build.scala index 95cfc83..a7f5f44 100644 --- a/redis/project/Build.scala +++ b/redis/project/Build.scala @@ -9,11 +9,12 @@ object MinimalBuild extends Build { lazy val typesafe = "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/" lazy val repo = if (buildVersion.endsWith("SNAPSHOT")) typesafeSnapshot else typesafe lazy val pk11 = "pk11 repo" at "http://pk11-scratch.googlecode.com/svn/trunk" - // for sedis 1.1.9 which hasn't been merged to master and doesn't exist in any repo yet + // for sedis 1.1.9 which hasn't been merged to master and doesn't exist in any public repo yet lazy val mavenLocal = "Maven Local" at Path.userHome.asFile.toURI.toURL + ".m2/repository" lazy val root = Project(id = "play-plugins-redis", base = file("."), settings = Project.defaultSettings).settings( - version := "2.2.1", + version := "2.2.1-SNAPSHOT", scalaVersion := "2.10.2", + //publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/.m2/repository"))), publishTo <<= (version) { version: String => val nexus = "https://private-repo.typesafe.com/typesafe/" if (version.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "maven-snapshots/") diff --git a/redis/sample/app/Global.java b/redis/sample/app/Global.java index 7657bea..247cfe3 100644 --- a/redis/sample/app/Global.java +++ b/redis/sample/app/Global.java @@ -10,6 +10,8 @@ public class Global extends GlobalSettings { public void onStart(Application app) { JedisPool p = app.plugin(RedisPlugin.class).jedisPool(); + // uncomment to test sentinel setup + //JedisSentinelPool p = app.plugin(RedisPlugin.class).jedisSentinelPool(); Jedis j = p.getResource(); j.set("foo","yay"); p.returnResource(j); diff --git a/redis/sample/app/controllers/Application.java b/redis/sample/app/controllers/Application.java index c5b0418..f713ac3 100644 --- a/redis/sample/app/controllers/Application.java +++ b/redis/sample/app/controllers/Application.java @@ -13,6 +13,8 @@ public class Application extends Controller { public static Result index() { JedisPool p = Play.application().plugin(RedisPlugin.class).jedisPool(); + // uncomment to test sentinel setup + //JedisSentinelPool p = Play.application().plugin(RedisPlugin.class).jedisSentinelPool(); Jedis j = p.getResource(); String r = j.get("foo") + " - foo2:" + j.get("foo2"); p.returnResource(j); diff --git a/redis/sample/conf/application.conf b/redis/sample/conf/application.conf index 56c883b..7be625f 100644 --- a/redis/sample/conf/application.conf +++ b/redis/sample/conf/application.conf @@ -1,6 +1,12 @@ # This is the main configuration file for the application. # ~~~~~ +# enable to test sentinel setup +redis.sentinel.mode=false +redis.sentinel.hosts=["localhost:26379", "localhost:26380"] +redis.master.name=mymaster +#redis.key.prefix=AppName + # Secret key # ~~~~~ # The secret key is used to secure cryptographics functions. diff --git a/redis/sample/project/Build.scala b/redis/sample/project/Build.scala index e0cdaec..69afee5 100644 --- a/redis/sample/project/Build.scala +++ b/redis/sample/project/Build.scala @@ -7,7 +7,7 @@ object ApplicationBuild extends Build { val appVersion = "1.0-SNAPSHOT" val appDependencies = Seq( - "com.typesafe" %% "play-plugins-redis" % "2.2.0", + "com.typesafe" %% "play-plugins-redis" % "2.2.1-SNAPSHOT", "com.typesafe.play" %% "play-cache" % "2.2.0" ) diff --git a/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala b/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala index 61e8bac..4fec843 100644 --- a/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala +++ b/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala @@ -45,6 +45,9 @@ class RedisPlugin(app: Application) extends CachePlugin { private lazy val masterName = app.configuration.getString("redis.master.name") .getOrElse("mymaster") + private lazy val keyPrefix = app.configuration.getString("redis.key.prefix") + .getOrElse("") + /** * provides access to the underlying jedis Pool */ @@ -172,16 +175,20 @@ class RedisPlugin(app: Application) extends CachePlugin { } + private def getFullKey(key: String): String = { + if (keyPrefix.length > 0) keyPrefix + ":" + key else key + } + private def setValue(client: Jedis, key: String, value: String, expiration: Int) { - client.set(key, value) - if (expiration != 0) client.expire(key, expiration) + client.set(getFullKey(key), value) + if (expiration != 0) client.expire(getFullKey(key), expiration) } def remove(key: String): Unit = { if (sentinelMode) { - sedisSentinelPool.withJedisClient { client => client.del(key) } + sedisSentinelPool.withJedisClient { client => client.del(getFullKey(key)) } } else { - sedisPool.withJedisClient { client => client.del(key) } + sedisPool.withJedisClient { client => client.del(getFullKey(key)) } } } @@ -199,9 +206,9 @@ class RedisPlugin(app: Application) extends CachePlugin { try { val rawData = { if (sentinelMode) { - sedisSentinelPool.withJedisClient { client => client.get(key) } + sedisSentinelPool.withJedisClient { client => client.get(getFullKey(key)) } } else { - sedisPool.withJedisClient { client => client.get(key) } + sedisPool.withJedisClient { client => client.get(getFullKey(key)) } } } rawData match { From 6be636e00da8f0be3f8f1f32906ea8128168a9b3 Mon Sep 17 00:00:00 2001 From: Ahsan Rabbani Date: Sun, 5 Jan 2014 17:27:48 -0500 Subject: [PATCH 6/8] added support for JedisSentinelPool --- redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala b/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala index 4fec843..be75813 100644 --- a/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala +++ b/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala @@ -40,7 +40,7 @@ class RedisPlugin(app: Application) extends CachePlugin { .getOrElse(false) private lazy val sentinelHosts : java.util.List[String] = app.configuration.getStringList("redis.sentinel.hosts") - .getOrElse(seqAsJavaList(List("localhost:6379"))) + .getOrElse(seqAsJavaList(List("localhost:26379"))) private lazy val masterName = app.configuration.getString("redis.master.name") .getOrElse("mymaster") From aa971236c3c77174042852c71efeb696abac6b6a Mon Sep 17 00:00:00 2001 From: Ahsan Rabbani Date: Wed, 8 Jan 2014 13:43:35 -0500 Subject: [PATCH 7/8] added support for JedisSentinelPool --- redis/project/Build.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/redis/project/Build.scala b/redis/project/Build.scala index a7f5f44..97ab363 100644 --- a/redis/project/Build.scala +++ b/redis/project/Build.scala @@ -9,8 +9,8 @@ object MinimalBuild extends Build { lazy val typesafe = "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/" lazy val repo = if (buildVersion.endsWith("SNAPSHOT")) typesafeSnapshot else typesafe lazy val pk11 = "pk11 repo" at "http://pk11-scratch.googlecode.com/svn/trunk" - // for sedis 1.1.9 which hasn't been merged to master and doesn't exist in any public repo yet - lazy val mavenLocal = "Maven Local" at Path.userHome.asFile.toURI.toURL + ".m2/repository" + // for jedis-2.2.2-SNAPSHOT which sedis 1.2.0 depends on + lazy val sonatype = "sonatype repo" at "http://oss.sonatype.org/content/groups/public" lazy val root = Project(id = "play-plugins-redis", base = file("."), settings = Project.defaultSettings).settings( version := "2.2.1-SNAPSHOT", scalaVersion := "2.10.2", @@ -23,11 +23,11 @@ object MinimalBuild extends Build { organization := "com.typesafe", resolvers += repo, resolvers += pk11, - resolvers += mavenLocal, + resolvers += sonatype, javacOptions += "-Xlint:unchecked", libraryDependencies += "biz.source_code" % "base64coder" % "2010-12-19", libraryDependencies += "com.typesafe" %% "play-plugins-util" % buildVersion, libraryDependencies += "com.typesafe.play" %% "play-cache" % buildVersion % "provided", - libraryDependencies += "org.sedis" % "sedis_2.10.0" % "1.1.9" + libraryDependencies += "org.sedis" % "sedis_2.10.0" % "1.2.0" ) } From b3c94ca74a0c1d44d533de3306b42b0eb3083d49 Mon Sep 17 00:00:00 2001 From: Ahsan Rabbani Date: Mon, 13 Jan 2014 18:13:50 -0500 Subject: [PATCH 8/8] added support for JedisSentinelPool --- redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala b/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala index be75813..aaf2c12 100644 --- a/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala +++ b/redis/src/main/scala/com/typesafe/plugin/RedisPlugin.scala @@ -125,6 +125,11 @@ class RedisPlugin(app: Application) extends CachePlugin { lazy val api = new CacheAPI { def set(key: String, value: Any, expiration: Int) { + if (value == null) { + Logger.warn("not setting key:"+ key + " because value is null") + return + } + var oos: ObjectOutputStream = null var dos: DataOutputStream = null try {