【问题标题】:Adding and retrieving Data sets to Redis using StackExchange.Redis使用 StackExchange.Redis 向 Redis 添加和检索数据集
【发布时间】:2015-12-18 23:01:41
【问题描述】:

我是 Redis 新手。我可以使用此命令将数据存储和检索到 redis

hmset user:user1 12 13 14 15 

也是通过

来检索数据
hgetall user:user1

我想在我的 c# 程序上使用 stackExchange.redis 来做同样的事情。 我应该如何在 C# 中做到这一点?

【问题讨论】:

  • 是的,但找不到适合我的情况的确切方法
  • 这是我目前尝试过的,HashEntry[] hashfield = new HashEntry[4] // 包含哈希条目,redisDB.HashSet("user",hashfield);

标签: c# redis stackexchange.redis


【解决方案1】:

要在哈希中设置多个值,您可以调用以下 HashSet 方法重载:

ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
IDatabase db = redis.GetDatabase();
db.HashSet("user:user1", new HashEntry[] { new HashEntry("12", "13"), new HashEntry("14", "15") });

【讨论】:

  • 我想 StackExchange.Redis 的文档放在 stackoverflow.com 上是有道理的...
猜你喜欢
  • 2015-06-18
  • 2018-08-11
  • 2022-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多