dart 2.9.2(用于 flutter 应用程序)中是否有 "Azure cache for Redis" 的 redis 包,它在连接字符串中采用主机名、端口及其密钥?

Is there a redis package for "Azure cache for Redis" in dart 2.9.2 (for flutter app) which takes hostname, port and its key in the connection string?

我想在 flutter 应用程序中连接我的 Azure Redis 缓存。目前我已经在 dart 中为 redis 尝试了两个包,它们是 redis 1.3.0 and dartis 0.5.0.

示例:

import 'package:redis/redis.dart';
...
RedisConnection conn = new RedisConnection();
    conn
        .connect('localhost', 6379)
        .then((Command command) {
      print("yo2");
      command.send_object(["SET", "key1", "value1"]).then((var response) {
        print(response);
      });
    });

我输入了“SampleName.redis.cache.windows.net”而不是“localhost”。这是我得到的错误:

E/flutter ( 4861): [错误:flutter/shell/common/shell.cc(209)] Dart 错误:未处理的异常: E/flutter ( 4861): RedisError(需要 NOAUTH 身份验证。)

old package This is the package starred on Redis Website。但它与 >2.

版本不兼容

好的,我找到了解决方案。按以下方式使用您的密钥:

对于redis 1.3.0

...
 RedisConnection conn = new RedisConnection();
    conn
        .connect('SampleName.redis.cache.windows.net', 6379)
        .then((Command command) {
      print("yo2");
      command.send_object([
        "AUTH",
        "<YourKey>"
      ]).then((var response) {
        print(response);
      });

      command.send_object(["SET", "key1", "value1"]);
    });
...

对于dartis 0.5.0

...
final client = await redis.Client.connect(
        'redis://SampleName.redis.cache.windows.net:6379');

    // Runs some commands.
    final commands = client.asCommands<String, String>();
    await commands.auth("<YourKey>");
    // SET key value
    await commands.set('yo', 'yovalue');
...