コード例 #1
0
        public void Run()
        {
            // Use a profile that uses more resources to accomodate more data in-memory (faster!).
            var profile = new Profile
            {
                MemoryLimitInPercent = 98,
                MaxStoreCount        = 1,
                BTreeSlotLength      = 250
            };

            using (Sop.Caching.VirtualCache vc = new Sop.Caching.VirtualCache("MyCacheStore", true, null, profile))
            {
                _logger          = vc.Logger;
                _logger.LogLevel = Log.LogLevels.Verbose;
                _logger.Information("Start of VirtualCache demo.");
                Populate(vc);
                RetrieveAll(vc);
                _logger.Information("End of VirtualCache demo.");
                _logger.Information("You just 'cached' & 'accessed all' {0} records.", MaxCacheEntries);
            }
        }
コード例 #2
0
        public void Run()
        {
            const int LoopCount = 3;

            Sop.Caching.VirtualCache vc = new Sop.Caching.VirtualCache("MyCacheStore", true);
            for (int i = 0; i < LoopCount; i++)
            {
                _logger          = vc.Logger;
                _logger.LogLevel = Log.LogLevels.Verbose;
                _logger.Information("Start of VirtualCache MemoryCache Compare demo.");
                try
                {
                    ObjectCache oc = MemoryCache.Default;
                    if (i == 0)
                    {
                        Populate(vc);
                    }
                    else
                    {
                        Populate(vc);
                    }
                    //Populate(oc);
                    RetrieveAll(vc);
                    RetrieveAll(oc);
                    Compare(vc, oc);
                    _logger.Information("End of VirtualCache MemoryCache Compare demo.");
                    vc.Commit(true);
                }
                catch (TransactionRolledbackException)
                {
                    vc.Dispose();
                    vc = new Sop.Caching.VirtualCache("MyCacheStore");
                }
            }
            vc.Dispose();
        }