我剛剛開始使用ServiceStack,並在MVC4中創建了我的第一個服務。現在我想用Redis保存我的對象。我無法弄清楚如何讓它在Windows上運行,或者ServiceStack發行版已經包含了它。我也在考慮使用其中一個Redis雲實現,但我想先讓它在本地運行。如何在Windows上的Servicestack上開始使用Redis?
感謝
我剛剛開始使用ServiceStack,並在MVC4中創建了我的第一個服務。現在我想用Redis保存我的對象。我無法弄清楚如何讓它在Windows上運行,或者ServiceStack發行版已經包含了它。我也在考慮使用其中一個Redis雲實現,但我想先讓它在本地運行。如何在Windows上的Servicestack上開始使用Redis?
感謝
你需要(有關here和here,對博客文章)像Redis的Windows上。您可以使用repo stored on github。一旦你有了,你可以在Visual Studio中構建redis並運行它。
服務堆棧還有一個支持頁面here,其中包括指向runs Redis as a Windows Service的項目的鏈接。
編輯。我發現我還在一個月前玩過the project and blog post(它巧合地是由stackexchange寫的Jason)。
LATE UPDATE好了,我剛評論
做多「下載」和更「執行安裝程序來獲得強大的服務」像你這樣的NuGet包
不是做我發現這個Redis Nuget,允許您從命令行運行Redis,由MSOpenTech發佈,您可以使用ServiceStack.Redispackage
編輯,這是你如何使用它:
運行下面的代碼:
public class Message {
public long Id { get; set; }
public string Payload { get; set; }
}
static void Main(string[] args) {
List<string> messages = new List<string> {
"Hi there",
"Hello world",
"Many name is",
"Uh, my name is"
};
var client = new RedisClient("localhost");
var msgClient = client.As<Message>();
for (int i = 0; i < messages.Count; i++) {
Message newItem = new Message {
Id = msgClient.GetNextSequence(),
Payload = messages[i] };
msgClient.Store(newItem);
}
foreach (var item in msgClient.GetAll()) {
Console.WriteLine("{0} {1}", item.Id, item.Payload);
msgClient.DeleteById(item.Id);
}
Console.WriteLine("(All done, press enter to exit)");
Console.ReadLine();
}
輸出:
1 Hi there
2 Hello world
3 Many name is
4 Uh, my name is
(All done, press enter to exit)
謝謝。我確實嘗試了存儲在github上的repo,但只是拉動它沒有編譯的zip文件。我會再次嘗試使用git。 – 2013-05-13 12:34:04
@TrevordeKoekkoek。 Visual Studio損壞了我們很多,我也承認,當我不得不做更多的事情,比如使用Nuget包做「下載」和「執行安裝程序以獲得強大的服務」 - 你只需要改變一下檔次,你會沒事的。 – 2013-05-13 12:38:06
@TrevordeKoekkoek。哇,從字面上發表評論和想法「現在想知道Nuget上有什麼」 - 然後在2013年5月6日星期一添加redis-64。爲我們的集體啓發編輯的答案。 – 2013-05-13 12:44:35