Tre*_*oek 3 asp.net-mvc redis servicestack asp.net-mvc-4
我刚开始使用ServiceStack并在MVC4中创建了我的第一个服务.现在我想使用Redis保留我的对象.我无法弄清楚如何让它在Windows上运行或者ServiceStack发行版已经包含了这个.我也在考虑使用其中一个Redis云实现,但我想先让它在本地运行.
谢谢
你需要像Windows上的Redis这样的东西(这里和这里,关于它的博客文章).您可以使用存储在github上的repo.完成后,您可以在Visual Studio中构建redis并运行它.
Service Stack 在此处还有一个支持页面,包括指向将Redis作为Windows服务运行的项目的链接.
编辑.我已经找到了我大约一个月前玩过的项目和博客文章(巧合的是由来自stackexchange 的杰森撰写).
晚了更新好的,所以我评论之后不久
不仅仅是"下载"和"执行安装程序以获得强大的服务",就像使用Nuget软件包一样
我发现这个Redis Nuget允许你从命令行运行Redis,由MSOpenTech发布,你可以使用ServiceStack.Redis 包
编辑,这是你如何使用它:
运行以下代码:
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();
}
Run Code Online (Sandbox Code Playgroud)输出:
1 Hi there
2 Hello world
3 Many name is
4 Uh, my name is
(All done, press enter to exit)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1248 次 |
| 最近记录: |