Exemple #1
0
        private static bool PrepareClient(string server_name)
        {
            lastErrorMessage = String.Empty;

            try
            {
                //-------------------------
                // Configure Cache Client
                //-------------------------

                //Define Array for 1 Cache Host
                List <DataCacheServerEndpoint> servers = new List <DataCacheServerEndpoint>(1)
                {
                    new DataCacheServerEndpoint(server_name, 22233)
                };

                //Specify Cache Host Details
                //  Parameter 1 = host name
                //  Parameter 2 = cache port number

                //Create cache configuration
                DataCacheFactoryConfiguration configuration = new DataCacheFactoryConfiguration
                {
                    Servers              = servers,
                    SecurityProperties   = new DataCacheSecurity(DataCacheSecurityMode.None, DataCacheProtectionLevel.None),
                    LocalCacheProperties = new DataCacheLocalCacheProperties()
                };

                //Disable exception messages since this sample works on a cache aside
                //DataCacheClientLogManager.ChangeLogLevel(System.Diagnostics.TraceLevel.Off);

                //Pass configuration settings to cacheFactory constructor
                myCacheFactory = new DataCacheFactory(configuration);

                //Get reference to named cache called "default"
                myDefaultCache = myCacheFactory.GetCache("default");

                //specify all possible item and region operations
                const DataCacheOperations itemCacheOperations = DataCacheOperations.AddItem |
                                                                DataCacheOperations.ReplaceItem |
                                                                DataCacheOperations.RemoveItem |
                                                                DataCacheOperations.ClearRegion |
                                                                DataCacheOperations.CreateRegion;

                //add cache-level notification callback
                //all cache operations from a notifications-enabled cache
                DataCacheNotificationDescriptor ndCacheLvlAllOps = myDefaultCache.AddRegionLevelCallback("SobekCM", itemCacheOperations, myCacheLvlDelegate);
                myDefaultCache.CreateRegion(regionName);

                return(true);
            }
            catch (Exception ee)
            {
                lastErrorMessage = ee.Message;
                return(false);
            }
        }
        private static bool PrepareClient(string server_name)
        {
            lastErrorMessage = String.Empty;

            try
            {

                //-------------------------
                // Configure Cache Client
                //-------------------------

                //Define Array for 1 Cache Host
                List<DataCacheServerEndpoint> servers = new List<DataCacheServerEndpoint>(1)
                                                            {new DataCacheServerEndpoint(server_name, 22233)};

                //Specify Cache Host Details
                //  Parameter 1 = host name
                //  Parameter 2 = cache port number

                //Create cache configuration
                DataCacheFactoryConfiguration configuration = new DataCacheFactoryConfiguration
                                                                  {
                                                                      Servers = servers,
                                                                      SecurityProperties =new DataCacheSecurity( DataCacheSecurityMode.None, DataCacheProtectionLevel.None),
                                                                      LocalCacheProperties = new DataCacheLocalCacheProperties()
                                                                  };

                //Disable exception messages since this sample works on a cache aside
                //DataCacheClientLogManager.ChangeLogLevel(System.Diagnostics.TraceLevel.Off);

                //Pass configuration settings to cacheFactory constructor
                myCacheFactory = new DataCacheFactory(configuration);

                //Get reference to named cache called "default"
                myDefaultCache = myCacheFactory.GetCache("default");

                //specify all possible item and region operations
                const DataCacheOperations itemCacheOperations = DataCacheOperations.AddItem |
                                                                DataCacheOperations.ReplaceItem |
                                                                DataCacheOperations.RemoveItem |
                                                                DataCacheOperations.ClearRegion |
                                                                DataCacheOperations.CreateRegion;

                //add cache-level notification callback
                //all cache operations from a notifications-enabled cache
                DataCacheNotificationDescriptor ndCacheLvlAllOps = myDefaultCache.AddRegionLevelCallback("SobekCM", itemCacheOperations, myCacheLvlDelegate);
                myDefaultCache.CreateRegion(regionName);

                 return true;
            }
            catch ( Exception ee )
            {
                lastErrorMessage = ee.Message;
                return false;
            }
        }