AnyEvent-ConnPool

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

# AnyEvent::ConnPool
Simple asynchronous connection pool, based on anyevent.

## Description

Connection pool designed for asynchronous connections.

## Synopsis

    my $connpool = AnyEvent::ConnPool->new(
        constructor =>  sub {
            create_connection();
        },
        check       =>  {
            cb          =>  sub {
                my $conn = shift;
                if ($conn->ping()) {
                    return 1;
                }
            },
            interval    =>  10,
        },
        size    =>  10,
        init    =>  1,
    );

    # get next connection.
    my $unit = $connpool->get();
    my $conn = $unit->conn();

    # get connection by specified number.
    my $unit_1 = $connpool->get(1);

    # after that, it will be obtained by $connpool->get();
    # you can use it for transact handles.
    $unit_1->lock();

    ...;

    # unlocks connection, after that it will be returned to balance scheme.

    $unit->unlock();



( run in 0.589 second using v1.01-cache-2.11-cpan-f56aa216473 )