Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplifying code and make it more variable #13

Open
kinocz opened this issue Sep 17, 2015 · 0 comments
Open

simplifying code and make it more variable #13

kinocz opened this issue Sep 17, 2015 · 0 comments

Comments

@kinocz
Copy link

kinocz commented Sep 17, 2015

Not sure if I'm right, but this might suit sedis better. Added SPool which takes as constructor parameter redis.client.util.Pool[Jedis], which is parent class of both:

class Pool(override val underlying: JedisPool) extends SPool(underlying){
}

class SentinelPool(override val underlying: JedisSentinelPool) extends SPool(underlying){
}

class SPool(val underlying: redis.clients.util.Pool[Jedis]) {
  def withClient[T](body: Dress.Wrap => T): T = {
    val jedis: Jedis = underlying.getResource
    try {
      body(Dress.up(jedis))
    } finally {
      jedis.close()
    }
  }

  def withJedisClient[T](body: Jedis => T): T = {
    val jedis: Jedis = underlying.getResource
    try {
      body(jedis)
    } finally {
      jedis.close()
    }
  }
}

not making pull request, since I'm not sure if your original code is intended.

@kinocz kinocz changed the title simplyfing code and make it more variable simplifying code and make it more variable Sep 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant