I want to use TIdTCPClient
to connect to Redis from a web server application made with Delphi and TWebModule
.
Currently on WebModule creation I create a new TIdTCPClient
and connect to Redis, e.g.:
procedure TWebService.WebModuleCreate(Sender: TObject);-
begin
FClient := TIdTCPClient.Create();
FClient.Connect('REDIS_HOST', 6379);
end;
and on web module destroy, I disconnect and free the resource, e.g.:
procedure TWebService.WebModuleDestroy(Sender: TObject);
begin
FClient.Disconnect;
FClient.Free;
end;
All works... But this way I create a new connection on every new request and after a lot of time there is a growing number of TIME_WAIT
sockets.
I would like to implement a global connection pool with a fixed number of connections always open (eg.: 50) and use only those.
Has Indy something to manage a pool of TCP connections?
No, Indy does not provide anything for pooling TCP connections. You will have to implement your own pool of TIdTCPClient
objects in your own code.