Class RedisConnectionPool

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Integer getDatabaseIndex()
      final <T extends Any> T withConnection(Duration timeout, Function1<RedisConnection, T> fn) Acquires a connection from the pool and run the provides lamba with this connection.
      Unit close() Closes all connections of the pool.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • withConnection

         final <T extends Any> T withConnection(Duration timeout, Function1<RedisConnection, T> fn)

        Acquires a connection from the pool and run the provides lamba with this connection.

        If any exception is thrown, regardless which kind, then the connection is considered unrecoverable, is closed and not returned to the pool. It is relative cheap to create new connections to Redis and this is a much safer way then trying to figure out whether the exception was caused by from the provided lamba or from the Redis client code somehow.

        Parameters:
        timeout - max time to wait for an available connection.
        Returns:

        the value returned by the lamba

      • close

         Unit close()

        Closes all connections of the pool.