Árvore de páginas

Você está vendo a versão antiga da página. Ver a versão atual.

Comparar com o atual Ver Histórico da Página

« Anterior Versão 9 Próxima »

Desconecta o cliente do servidor

Sintaxe

oRedisAfter := oReisdClient:Disconnect()

Observações

O método ::Disconnect() permite que um cliente interrompa sua conexão com um servidor Redis. Isto permite que sejam liberados recursos alocados para conexão tanto no servidor quanto no cliente.

Deste modo, o servidor Redis pode atender a outros clientes.

Naturalmente, uma desconexão só faz sentido caso o cliente tenha de fato conseguido se conectar.

Exemplos

#include 'protheus.ch'
   
#define STD_REDIS_PORT 6379
#define DEFAULT_REDIS_AUTH ""
  
// Setup Redis
Static cRedisHost := "localhost"
   
User Function WoAuth()
  Local cMsg := ''
  
  // Creation of client object
  oRedisCli := tRedisClient():New()
  
  // Connection to the server, using default port 6379
  oRedisCli:Connect(cRedisHost, STD_REDIS_PORT)
  
  If oRedisCli:lConnected
    cMsg := "Successful connection to the server " + cRedisHost + ", at port "
    cMsg += cValToChar(STD_REDIS_PORT) + ", with authentication '" + DEFAULT_REDIS_AUTH + "'"
    ConOut(cMsg)
  
    oRedisCli:Disconnect()
    ConOut("The client disconnected from the server.")
    Return .T.
  EndIf
  
  cMsg := "Could not connect to the server " + cRedisHost + ", at port "
  cMsg += cValToChar(STD_REDIS_PORT) + ", with authentication '" + DEFAULT_REDIS_AUTH + "'"
  ConOut(cMsg)
  
Return .F.
  • Sem rótulos