使用 StackExchange.Redis 向 Redis 添加和检索数据集
Adding and retrieving Data sets to Redis using StackExchange.Redis
我是 Redis 新手。我可以使用此命令将数据存储和检索到 redis
hmset user:user1 12 13 14 15
我还要通过
检索数据
hgetall user:user1
我想在我的 C# 程序上使用 stackExchange.redis 做同样的事情。
我应该如何在 C# 中执行此操作?
要在散列中设置多个值,您可以调用以下 HashSet 方法重载:
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
IDatabase db = redis.GetDatabase();
db.HashSet("user:user1", new HashEntry[] { new HashEntry("12", "13"), new HashEntry("14", "15") });
我是 Redis 新手。我可以使用此命令将数据存储和检索到 redis
hmset user:user1 12 13 14 15
我还要通过
检索数据hgetall user:user1
我想在我的 C# 程序上使用 stackExchange.redis 做同样的事情。 我应该如何在 C# 中执行此操作?
要在散列中设置多个值,您可以调用以下 HashSet 方法重载:
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
IDatabase db = redis.GetDatabase();
db.HashSet("user:user1", new HashEntry[] { new HashEntry("12", "13"), new HashEntry("14", "15") });