Ejemplo n.º 1
0
        /// <summary>
        /// Sample code that uses this VirtualCache.
        /// </summary>
        public static void Run()
        {
            Console.WriteLine("{0}: Virtual Cache demo started...", DateTime.Now);
            MemoryExtender.ServerPath = "SopBin\\";
            MemoryExtender          vc     = new MemoryExtender();
            ISortedDictionaryOnDisk cache1 = vc.GetObjectCache(1);
            const int MaxCount             = 40000;

            for (int i = 0; i < MaxCount; i++)
            {
                cache1.Add(i, string.Format("{0} cached data", i));
            }

            Console.WriteLine("{0}: Finished inserting {1} records, reading 'em starts now...", DateTime.Now, MaxCount);
            cache1.MoveFirst();
            cache1.HintSequentialRead = true;
            for (int i = 0; i < MaxCount; i++)
            {
                string s = cache1.CurrentValue as string;
                if (string.IsNullOrEmpty(s) ||
                    s != string.Format("{0} cached data", i))
                {
                    Console.WriteLine("Error, data not found.");
                }
                cache1.MoveNext();
            }
            Console.WriteLine("{0}: Virtual Cache demo ended... {1} records were read.", DateTime.Now, MaxCount);
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            var demo = DemoType.OneHundredMillionInserts;
            //.PeopleDirectoryLargeDB;
            //.Store400;
            //.VirtualCacheMemoryExtenderMultipleClients;    //VirtualCacheMemoryExtenderReCreate;
            dynamic pd = null;

            switch (demo)
            {
            case DemoType.VirtualCacheMemoryExtenderMultipleClients:
                pd = new VirtualCacheMemoryExtenderMultipleClients();
                break;

            case DemoType.VirtualCacheThreaded:
                pd = new VirtualCacheThreaded();
                break;

            //case DemoType.VirtualCacheWithBackgroundRefreshDemo:
            //    pd = new VirtualCacheWithBackgroundRefreshDemo();
            //    break;
            case DemoType.VirtualCacheMemoryExtenderReCreate:
                pd = new VirtualCacheMemoryExtenderReCreate();
                break;

            case DemoType.PeopleDirectoryWithUpdateDelete:
                pd = new PeopleDirectoryWithUpdateDelete();
                break;

            case DemoType.VirtualCacheDemo:
                pd = new VirtualCacheDemo();
                break;

            case DemoType.VirtualCacheMemoryCacheCompare:
                pd = new VirtualCacheMemoryCacheCompare();
                break;

            case DemoType.RenameItemKeysOfStore:
                pd = new RenameItemsOfStore();
                break;

            case DemoType.ObjectDirectory:
                pd = new ObjectDirectory();
                break;

            case DemoType.ObjectDirectoryLINQ:
                pd = new ObjectDirectoryLINQ();
                break;

            case DemoType.PeopleDirectoryWithBigData:
                pd = new PeopleDirectoryWithBigData();
                break;

            //NOTE: Store rename is not supported in 4.7.
            //case DemoType.RenameStore:
            //    pd = new RenameStore();
            //    break;
            case DemoType.PeopleDirectoryXmlSerializableObject:
                pd = new PeopleDirectoryXmlSerializableObject();
                break;

            case DemoType.PeopleDirectoryWithBlobDataQueryFunc:
                pd = new PeopleDirectoryWithBlobDataQueryFunc();
                break;

            case DemoType.PeopleDirectoryWithBlobDataAddUniqueCheck:
                pd = new PeopleDirectoryWithBlobDataAddUniqueCheck();
                break;

            case DemoType.PeopleDirectoryWithBlobDataNull:
                pd = new PeopleDirectoryWithBlobDataNull();
                break;

            case DemoType.PeopleDirectoryWithUpdateLargeDBLitePersistence:
                pd = new PeopleDirectoryWithUpdateLargeDBLitePersistence();
                break;

            case DemoType.NestedSortedDictionary:
                pd = new NestedSortedDictionary();
                break;

            case DemoType.PeopleDirectoryWithMediumDB:
                pd = new PeopleDirectoryWithMediumDB();
                break;

            case DemoType.BayWind:
                pd = new BayWind();
                break;

            case DemoType.Store400:
                pd = new Store400();
                break;

            case DemoType.MemoryExtender:
                pd = new MemoryExtender();
                break;

            case DemoType.MemoryExtenderGenerics:
                pd = new MemoryExtenderGenerics();
                break;

            case DemoType.IterateDescendingOrder:
                pd = new IterateDescendingOrder();
                break;

            case DemoType.ManageMultipleFiles:
                pd = new ManageMultipleFiles();
                break;

            case DemoType.PeopleDirectoryAsIPersistent:
                pd = new PeopleDirectoryAsIPersistent();
                break;

            case DemoType.PeopleDirectory:
                pd = new PeopleDirectory();
                break;

            case DemoType.PeopleDirectoryWithUpdate:
                pd = new PeopleDirectoryWithUpdate();
                break;

            case DemoType.PeopleDirectoryWithBlobData:
                pd = new PeopleDirectoryWithBlobData();
                break;

            case DemoType.PeopleDirectoryWithBlobDataUpdate:
                pd = new PeopleDirectoryWithBlobDataUpdate();
                break;

            case DemoType.PeopleDirectoryWithBlobDataDelete:
                pd = new PeopleDirectoryWithBlobDataDelete();
                break;

            case DemoType.PeopleDirectoryLargeDB:
                pd = new PeopleDirectoryLargeDB();
                break;

            case DemoType.ManyClientSimulator:
                pd = new ManyClientSimulator();
                pd.DeleteDataFolder(ManyClientSimulator.ServerFilename);
                // simulate numerous parallel clients accessing the same Store.
                // this demonstrates multi-reader, single writer SOP Store feature.
                pd.ThreadCount = 500;
                pd.DataInsertionThreadCount = 150;
                //pd.ThreadCount = 5;
                //pd.DataInsertionThreadCount = 2;
                pd.Threaded = true;
                break;

            case DemoType.OneHundredMillionInserts:
                pd = new OneHundredMillionInserts();
                pd.DeleteDataFolder(OneHundredMillionInserts.ServerFilename);
                pd.Insert = true;
                pd.Run();
                pd.Insert = false;
                break;
            }
            pd.Run();

            Console.WriteLine("Press any key to exit the App.");
            Console.ReadLine();
        }