Exemple #1
0
 public void MicrosoftMemory()
 {
     IMemoryCacheCache.Set(Rand.Next(), new { A = 1 }, new CacheEntryOptions()
     {
         AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(1)
     });
 }
Exemple #2
0
        public void Setup()
        {
            var Services = new ServiceCollection().AddOptions()
                           .Configure <InMemoryCacheOptions>(options => options.ScanFrequency         = TimeSpan.FromSeconds(10))
                           .Configure <MemoryCacheOptions>(options => options.ExpirationScanFrequency = TimeSpan.FromSeconds(10));

            Services.AddCanisterModules(x => x.RegisterInMemoryHoard().RegisterMemoryCacheHoard());
            InMemoryCache     = Canister.Builder.Bootstrapper.Resolve <Cache>().GetOrAddCache("In Memory");
            IMemoryCacheCache = Canister.Builder.Bootstrapper.Resolve <Cache>().GetOrAddCache("Microsoft.Extensions.Caching.Memory");

            InMemoryCache.Set("Testing", new { A = 1 });
            IMemoryCacheCache.Set("Testing", new { A = 1 });
        }
Exemple #3
0
        public void Setup()
        {
            Rand = new Random();
            var Services = new ServiceCollection().AddOptions()
                           .Configure <InMemoryCacheOptions>(options => { options.ScanFrequency = TimeSpan.FromSeconds(10); })
                           .Configure <MemoryCacheOptions>(options => { options.ExpirationScanFrequency = TimeSpan.FromSeconds(10); });

            Services.AddCanisterModules(x => x.RegisterInMemoryHoard().RegisterMemoryCacheHoard());
            InMemoryCache     = Canister.Builder.Bootstrapper.Resolve <Cache>().GetOrAddCache("In Memory");
            IMemoryCacheCache = Canister.Builder.Bootstrapper.Resolve <Cache>().GetOrAddCache("Microsoft.Extensions.Caching.Memory");

            InMemoryCache.Set("Update", new { A = 1 }, new CacheEntryOptions()
            {
                AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(1)
            });
            IMemoryCacheCache.Set("Update", new { A = 1 }, new CacheEntryOptions()
            {
                AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(1)
            });
        }
Exemple #4
0
 public void MicrosoftMemory()
 {
     IMemoryCacheCache.TryGetValue("Testing", out object _);
 }