1
我试图找出如何做寻呼SS.Redis,我使用:ServiceStack的Redis如何实现分页
var todos = RedisManager.ExecAs<Todo>(r => r.GetLatestFromRecentsList(skip,take));
返回0,但我敢肯定的数据库不是空的,因为r.GetAll()
返回事物列表。什么是正确的方法来做到这一点?
编辑:这里是代码:
public class ToDoRepository : IToDoRepository
{
public IRedisClientsManager RedisManager { get; set; } //Injected by IOC
public Todo GetById(long id) {
return RedisManager.ExecAs<Todo>(r => r.GetById(id));
}
public IList<Todo> GetAll() {
return RedisManager.ExecAs<Todo>(r => r.GetAll());
}
public IList<Todo> GetAll(int from, int to) {
var todos = RedisManager.ExecAs<Todo>(r => r.GetLatestFromRecentsList(from,to));
return todos;
}
public Todo NewOrUpdate(Todo todo) {
RedisManager.ExecAs<Todo>(r =>
{
if (todo.Id == default(long)) todo.Id = r.GetNextSequence(); //Get next id for new todos
r.Store(todo); //save new or update
});
return todo;
}
public void DeleteById(long id) {
RedisManager.ExecAs<Todo>(r => r.DeleteById(id));
}
public void DeleteAll() {
RedisManager.ExecAs<Todo>(r => r.DeleteAll());
}
}
看起来像我不明白我使用的功能的含义。我们在哪里可以获得SS.Redis文档来解释SS Redis函数和数据如何进行结构化? – Tom
有大量的文档,首先是:http://www.servicestack.net/docs/category/Redis%20Client然后包含在http://stackoverflow.com/a/8919931/85785中的链接 - 然后看看单元测试如果仍然不确定。 – mythz
我可以再次重申我的q ...当我使用r.Store(todo);我怎样才能得到分页的项目,但不要调用r.GetAll(); ...其次,我不确定什么是RecentsList功能的用法。我只能猜测它可以访问你刚刚使用的列表。如果我关闭redis服务器,我不能再以这种方式得到我的待办事项列表。所以如果我想要一个分页的待办事项列表,调用最近的列表可能不能保证结果,我可能需要调用另一个函数来做到这一点,对吗? – Tom