1
1
using System . Collections . Generic ;
2
2
using RedisAdminUI . DataSource . Northwind ;
3
3
using RedisAdminUI . ServiceModel . Operations . App ;
4
+ using ServiceStack ;
4
5
using ServiceStack . Redis ;
5
6
6
7
namespace RedisAdminUI . ServiceInterface . App
@@ -21,32 +22,47 @@ public object Any(PopulateRedisWithData request)
21
22
Redis . StoreAll ( NorthwindData . Orders ) ;
22
23
Redis . StoreAll ( NorthwindData . Products ) ;
23
24
Redis . StoreAll ( NorthwindData . OrderDetails ) ;
24
- //Redis.StoreAll(NorthwindData.CustomerCustomerDemos);
25
25
Redis . StoreAll ( NorthwindData . Regions ) ;
26
26
Redis . StoreAll ( NorthwindData . Territories ) ;
27
27
Redis . StoreAll ( NorthwindData . EmployeeTerritories ) ;
28
28
29
29
LoadDifferentKeyTypes ( Redis ) ;
30
30
31
+ //Just load collections in DB 1
32
+ using ( var redisDb1 = new RedisClient ( Redis . Host , Redis . Port , db : 1 ) )
33
+ {
34
+ LoadDifferentKeyTypes ( redisDb1 ) ;
35
+ }
36
+
31
37
return new PopulateRedisWithDataResponse ( ) ;
32
38
}
33
39
34
- protected void LoadDifferentKeyTypes ( IRedisClient client )
40
+ protected void LoadDifferentKeyTypes ( IRedisClient redis )
35
41
{
36
- var items = new List < string > { "one" , "two" , "three" , "four" } ;
37
- var map = new Dictionary < string , string > {
38
- { "A" , "one" } ,
39
- { "B" , "two" } ,
40
- { "C" , "three" } ,
41
- { "D" , "four" } ,
42
- } ;
43
-
44
- items . ForEach ( x => Redis . Set ( "urn:testkeytypes:string:" + x , x ) ) ;
45
- items . ForEach ( x => Redis . AddItemToList ( "urn:testkeytypes:list" , x ) ) ;
46
- items . ForEach ( x => Redis . AddItemToSet ( "urn:testkeytypes:set" , x ) ) ;
47
- var i = 0 ;
48
- items . ForEach ( x => Redis . AddItemToSortedSet ( "urn:testkeytypes:zset" , x , i ++ ) ) ;
49
- Redis . SetRangeInHash ( "urn:testkeytypes:hash" , map ) ;
42
+ int A = 'A' ;
43
+ int Z = 'Z' ;
44
+ var letters = ( Z - A + 1 ) . Times ( i => ( ( char ) ( i + A ) ) . ToString ( ) ) ;
45
+ var numbers = new [ ] { "zero" , "one" , "two" , "three" , "four" , "five" , "six" , "seven" , "eight" , "nine" } ;
46
+
47
+ var pos = 0 ;
48
+ letters . Each ( x => redis . Set ( "string:letters/" + x , x ) ) ;
49
+ numbers . Each ( x => redis . Set ( "string:numbers/" + pos ++ , x ) ) ;
50
+
51
+ letters . Each ( x => redis . AddItemToList ( "list:letters" , x ) ) ;
52
+ numbers . Each ( x => redis . AddItemToList ( "list:numbers" , x ) ) ;
53
+
54
+ letters . Each ( x => redis . AddItemToSet ( "set:letters" , x ) ) ;
55
+ numbers . Each ( x => redis . AddItemToSet ( "set:numbers" , x ) ) ;
56
+
57
+ pos = 0 ;
58
+ letters . Each ( x => redis . AddItemToSortedSet ( "zset:letters" , x , pos ++ ) ) ;
59
+ pos = 0 ;
60
+ numbers . Each ( x => redis . AddItemToSortedSet ( "zset:numbers" , x , pos ++ ) ) ;
61
+
62
+ pos = 0 ;
63
+ letters . Each ( x => redis . SetEntryInHash ( "hash:letters" , x , ( pos ++ ) . ToString ( ) ) ) ;
64
+ pos = 0 ;
65
+ numbers . Each ( x => redis . SetEntryInHash ( "hash:numbers" , x , ( pos ++ ) . ToString ( ) ) ) ;
50
66
}
51
67
}
52
68
}
0 commit comments