77using Garnet . server ;
88using Microsoft . Extensions . DependencyInjection ;
99using Microsoft . Extensions . Logging ;
10+ using Microsoft . Extensions . Configuration ;
1011
1112namespace CacheManager . Config . Tests ;
1213
@@ -34,8 +35,16 @@ public static async Task Main(string[] args)
3435 var iterations = 100 ;
3536 try
3637 {
38+ var configuration = new ConfigurationBuilder ( )
39+ . AddJsonFile ( "cache.json" )
40+ . Build ( ) ;
41+
42+
3743 var services = new ServiceCollection ( ) ;
3844
45+ services . AddCacheManager ( ) ;
46+ services . AddCacheManagerConfiguration ( configuration , c => c . WithJsonSerializer ( ) ) ;
47+
3948 services . AddLogging ( c =>
4049 {
4150 c . AddSystemdConsole ( ) ;
@@ -47,49 +56,51 @@ public static async Task Main(string[] args)
4756
4857 using var server = StartServer ( loggerFactory ) ;
4958
50- var builder = new Core . CacheConfigurationBuilder ( "myCache" ) ;
59+ var cacheA = provider . GetRequiredService < ICacheManager < string > > ( ) ;
5160
52- builder
53- . WithRetryTimeout ( 500 )
54- . WithMaxRetries ( 3 ) ;
61+ //var builder = new Core.CacheConfigurationBuilder("myCache");
5562
56- builder
57- . WithDictionaryHandle ( )
58- . WithExpiration ( ExpirationMode . Absolute , TimeSpan . FromSeconds ( 20 ) )
59- . DisableStatistics ( ) ;
63+ //builder
64+ // .WithRetryTimeout(500)
65+ // .WithMaxRetries(3);
6066
61- builder
62- . WithRedisCacheHandle ( "redis" , true )
63- . WithExpiration ( ExpirationMode . Absolute , TimeSpan . FromMinutes ( 60 ) )
64- . DisableStatistics ( ) ;
67+ // builder
68+ // .WithDictionaryHandle( )
69+ // .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromSeconds(20 ))
70+ // .DisableStatistics();
6571
66- builder . WithRedisBackplane ( "redis" ) ;
72+ //builder
73+ // .WithRedisCacheHandle("redis", true)
74+ // .WithExpiration(ExpirationMode.Absolute, TimeSpan.FromMinutes(60))
75+ // .DisableStatistics();
6776
68- builder . WithRedisConfiguration ( "redis" , config =>
69- {
70- config
71- //.UseTwemproxy()
72- //.UseCompatibilityMode("2.4")
73- . WithAllowAdmin ( )
74- . WithDatabase ( 0 )
75- . WithConnectionTimeout ( 5000 )
76- . EnableKeyspaceEvents ( )
77- . WithEndpoint ( "127.0.0.1" , 6379 ) ;
78- } ) ;
77+ //builder.WithRedisBackplane("redis");
78+
79+ //builder.WithRedisConfiguration("redis", config =>
80+ //{
81+ // config
82+ // //.UseTwemproxy()
83+ // //.UseCompatibilityMode("2.4")
84+ // .WithAllowAdmin()
85+ // .WithDatabase(0)
86+ // .WithConnectionTimeout(5000)
87+ // .EnableKeyspaceEvents()
88+ // .WithEndpoint("127.0.0.1", 6379);
89+ //});
7990
8091 //builder.WithRedisConfiguration("redis", "localhost:22121");
8192
82- builder . WithBondCompactBinarySerializer ( ) ;
93+ // builder.WithBondCompactBinarySerializer();
8394
84- var cacheA = new BaseCacheManager < string > ( builder . Build ( ) ) ;
85- var cacheB = new BaseCacheManager < string > ( builder . Build ( ) ) ;
95+ // var cacheA = new BaseCacheManager<string>(builder.Build());
96+ // var cacheB = new BaseCacheManager<string>(builder.Build());
8697 cacheA . Clear ( ) ;
8798
8899 cacheA . Add ( "key" , "value" , "region" ) ;
89100
90101 var val = cacheA . Get ( "key" , "region" ) ;
91102
92- var val2 = cacheB . AddOrUpdate ( "key" , "region" , "added?" , ( v ) => v + "updated" ) ;
103+ // var val2 = cacheB.AddOrUpdate("key", "region", "added?", (v) => v + "updated");
93104
94105 await Task . Delay ( 100 ) ;
95106
0 commit comments