我正在使用 StackExchange.Redis 访问 Redis 实例。
我有以下工作 C# 代码:
public static void Demo()
{
ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("xxx.redis.cache.windows.net,ssl=true,password=xxx");
IDatabase cache = connection.GetDatabase();
cache.StringSet("key1", "value");
}
这是我希望等效的 F# 代码:
let Demo() =
let cx = ConnectionMultiplexer.Connect @"xxx.redis.cache.windows.net,ssl=true,password=xxx"
let cache = cx.GetDatabase()
cache.StringSet("key1", "value") |> ignore
但是,这不会编译 - “方法 StringSet 没有重载匹配”。StringSet 方法需要 RedisKey 和 RedisValue 类型的参数,并且 C# 中似乎有一些编译器魔法将调用代码中的字符串转换为 RedisKey 和 RedisValue。F# 中似乎不存在这种魔法。有没有办法达到相同的结果?