This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
tests/ServiceStack.Redis.Tests/Examples Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments