Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 65481d3

Browse files
committed
Add UseCase for Redis Product
1 parent d18d039 commit 65481d3

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System.Linq;
2+
using NUnit.Framework;
3+
using ServiceStack.Text;
4+
5+
namespace ServiceStack.Redis.Tests.Examples
6+
{
7+
[TestFixture]
8+
public class ServiceStack_Redis_UseCase
9+
{
10+
public class Todo
11+
{
12+
public long Id { get; set; }
13+
public string Content { get; set; }
14+
public int Order { get; set; }
15+
public bool Done { get; set; }
16+
}
17+
18+
[Test]
19+
public void Can_Add_Update_and_Delete_Todo_item()
20+
{
21+
using (var redisManager = new PooledRedisClientManager())
22+
using (var redis = redisManager.GetClient())
23+
{
24+
var redisTodos = redis.As<Todo>();
25+
var todo = new Todo
26+
{
27+
Id = redisTodos.GetNextSequence(),
28+
Content = "Learn Redis",
29+
Order = 1,
30+
};
31+
32+
redisTodos.Store(todo);
33+
34+
Todo savedTodo = redisTodos.GetById(todo.Id);
35+
savedTodo.Done = true;
36+
redisTodos.Store(savedTodo);
37+
38+
"Updated Todo:".Print();
39+
redisTodos.GetAll().ToList().PrintDump();
40+
41+
redisTodos.DeleteById(savedTodo.Id);
42+
43+
"No more Todos:".Print();
44+
redisTodos.GetAll().ToList().PrintDump();
45+
}
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)