redis密码验证

redis密码验证

编辑redis.windows-service.conf配置文件

登陆验证代码

/// <summary>
/// 创建一个新的redis客户端
/// </summary>
/// <param name="AHostName">redis IP地址</param>
/// <param name="APort">redis端口</param>
/// <param name="ALibName">何种通讯</param>
/// <param name="APassword">redis登陆密码</param>
/// <returns></returns>
function NewClient(AHostName: string = 'localhost'; APort: Word = 6379;
  ALibName: string = 'indy'; APassword: string = 'yn'): IRedisClient;
begin
  Result := TRedisClient.Create(AHostName, APort, ALibName);
  try
    TRedisClient(Result).Connect;
    if APassword <> '' then
      Result.AUTH(APassword);  //验证redis密码
  except
    Result := nil;
    raise;
  end;
end;

  

posted @ 2020-02-11 11:30  delphi中间件  阅读(566)  评论(0编辑  收藏  举报