redis - 如何在Redis List中使用where条件查找记录?

标签 redis stackexchange.redis

我正在使用 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 whose Name=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/

相关文章:

python - 优化 Django 架构以加速管理中的 ListView

c# - 从 Redis 缓存数据库中获取所有键

stackexchange.redis - 我可以使用 StackExchange.Redis 在 Redis 中存储空值吗?

c# - 为什么错误没有连接可用于服务此操作 : SETEX while writing to Redis Cache in C# console application and how to solve it

asp.net - 通过 StackExchange.Redis 连接到 Redis 服务

twitter - Redis pubsub 和 twitter 就像新闻源一样?

docker - Docker 中的 rq : "Could not resolve a Redis connection" with an otherwise working redis connection

redis - 不同版本的hget结果不同

redis - spring data redis - 监听过期事件

c# - 在 StackExchange.Redis 中将对象转换为 HashEntry