Skip to content

simplifying code and make it more variable #13

Description

@kinocz

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions