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