Class RedisConnectionPool

    • 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.