我已经使用 ServiceStack.Redis 几天了,我的应用程序中的最后一个难题是搜索缓存。
我有一个简单的对象
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public int Age { get; set; }
public string Profession { get; set; }
}
例如我想返回所有姓名为 Joe 且年龄超过 10 岁的人
什么是更好的速度明智?
- 针对将返回 ID 列表的数据库运行查询,而不是通过 Redis .GetByIds 函数获取匹配的记录。
或
- 由于 RedisClient 没有原生的 Linq 支持(没有 AsEnumerable 只有 iList)来运行 GetAll() 而不是执行进一步的过滤。
有没有人有这方面的经验?
最佳答案
我一直在为同样的问题而苦苦挣扎,我的选择是保存一组代表属性的“轻量级”数据我需要识别整个寄存器o属性我需要过滤整组数据,然后转到如有必要,其余的数据库。
我刚开始使用 redis,我知道这可能不是最好的选择,但它比每次都去数据库过滤信息要好。
希望知道您是否找到了更好的解决方案:)
关于c# - ServiceStack.Redis 搜索缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30110968/