Quellcode durchsuchen

[dataRedis] some improvements

Exilon vor 3 Jahren
Ursprung
Commit
eff8ef72f0
1 geänderte Dateien mit 12 neuen und 14 gelöschten Zeilen
  1. 12 14
      Quick.Data.Redis.pas

+ 12 - 14
Quick.Data.Redis.pas

@@ -7,7 +7,7 @@
   Author      : Kike Pérez
   Author      : Kike Pérez
   Version     : 1.0
   Version     : 1.0
   Created     : 22/02/2020
   Created     : 22/02/2020
-  Modified    : 06/10/2021
+  Modified    : 15/10/2021
 
 
   This file is part of QuickLib: https://github.com/exilon/QuickLib
   This file is part of QuickLib: https://github.com/exilon/QuickLib
 
 
@@ -181,11 +181,11 @@ end;
 destructor TRedisClient.Destroy;
 destructor TRedisClient.Destroy;
 begin
 begin
   try
   try
-    if fTCPClient.Connected then RedisQUIT;
-    fTCPClient.IOHandler.InputBuffer.Clear;
-    fTCPClient.IOHandler.WriteBufferFlush;
-    if fTCPClient.Connected then fTCPClient.Disconnect(False);
-    fTCPClient.Free;
+    try
+      Disconnect;
+    finally
+      fTCPClient.Free;
+    end;
   except
   except
     //avoid closing errors
     //avoid closing errors
   end;
   end;
@@ -199,24 +199,21 @@ begin
     RedisQUIT;
     RedisQUIT;
     fTCPClient.IOHandler.InputBuffer.Clear;
     fTCPClient.IOHandler.InputBuffer.Clear;
     fTCPClient.IOHandler.WriteBufferFlush;
     fTCPClient.IOHandler.WriteBufferFlush;
+    if fTCPClient.Connected then fTCPClient.Disconnect(False);
   end;
   end;
   fConnected := False;
   fConnected := False;
 end;
 end;
 
 
 procedure TRedisClient.Connect;
 procedure TRedisClient.Connect;
 begin
 begin
-  if not fTCPClient.Connected then
-  begin
-    fTCPClient.Host := fHost;
-    fTCPClient.Port := fPort;
-    fTCPClient.ConnectTimeout := fConnectionTimeout;
-    fTCPClient.ReadTimeout := fConnectionTimeout;
-  end;
   try
   try
-    fTCPClient.Connect; //first connection
     //connect password and database
     //connect password and database
     if not fTCPClient.Connected then
     if not fTCPClient.Connected then
     begin
     begin
+      fTCPClient.Host := fHost;
+      fTCPClient.Port := fPort;
+      fTCPClient.ConnectTimeout := fConnectionTimeout;
+      fTCPClient.ReadTimeout := fConnectionTimeout;
       fTCPClient.Connect;
       fTCPClient.Connect;
       if not fTCPClient.Connected then raise ERedisConnectionError.Create('Can''t connect to Redis Server!');
       if not fTCPClient.Connected then raise ERedisConnectionError.Create('Can''t connect to Redis Server!');
     end;
     end;
@@ -316,6 +313,7 @@ begin
             Result.Response := TrimResponse(res);
             Result.Response := TrimResponse(res);
             Result.IsDone := True;
             Result.IsDone := True;
           end;
           end;
+        else Result.Response := TrimResponse(res);
       end;
       end;
     end;
     end;
   except
   except