我正在使用 cloud structure redis Redis 缓存和 Redis 列表库。
// Settings should holds in static variable
public static class RedisServer
{
public static readonly RedisSettings Default = new RedisSettings("127.0.0.1");
}
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
var mylist = new RedisList<Person>(RedisServer.Default, "test-list-key");
await mylist.LeftPush(new[] { new Person { Name = "Tom" , Age = 12 }, new Person { Name = "Mary" , Age = 23} });
I want to find out record from
mylist
whoseName=Tom and Age=12
最佳答案
Redis 根本不是那样工作的。查询列表时,您不能执行与 where ...
等效的操作。您可以推送、弹出和查询范围等 (here's the full list of "list" commands)。 是“[list] 中[content] 的索引是什么”,但是为此你需要知道对象的整个有效负载(在完全相同的形式),而不仅仅是个别作品。您可以在 Redis 中手动构建索引,但是:这是一个相对高级的主题。
关于redis - 如何在Redis List中使用where条件查找记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37481419/