当前位置: 首页>>代码示例>>C#>>正文


C# DataCache.CreateRegion方法代码示例

本文整理汇总了C#中DataCache.CreateRegion方法的典型用法代码示例。如果您正苦于以下问题:C# DataCache.CreateRegion方法的具体用法?C# DataCache.CreateRegion怎么用?C# DataCache.CreateRegion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataCache的用法示例。


在下文中一共展示了DataCache.CreateRegion方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AzureCacheStore

	    public AzureCacheStore(DataCache cache, string cacheRegion)
        {
            _cacheRegion = cacheRegion;
	        _cache = cache;

            if (!string.IsNullOrEmpty(_cacheRegion))
                _cache.CreateRegion(_cacheRegion);
        }
开发者ID:yyf919,项目名称:CacheCow,代码行数:8,代码来源:AzureCacheStore.cs

示例2: VelocityCacheResolver

        static VelocityCacheResolver()
        {
            _Factory = new DataCacheFactory();
            _Cache = _Factory.GetCache(ConstantHelper.VelocityCacheName);

            try
            {
                _Cache.CreateRegion(REGION_NAME, false);
            }
            catch
            {
                // if the region already exists, this will throw an exception.
                // Velocity has no API to check if a region exists or not.
            }
        }
开发者ID:modulexcite,项目名称:dropthings,代码行数:15,代码来源:VelocityCacheResolver.cs

示例3: AzureDataCacheDirectory

        public AzureDataCacheDirectory(string cacheRegion, DataCache persistantCache)
        {
            _cacheRegion = cacheRegion;
            _persistantCache = persistantCache;
            _fileSystemNamespace = cacheRegion + "::Files::";
            _fileSizeNamespace = cacheRegion + "::FileSize::";
            _modifiedNamespace = cacheRegion + "::Modified::";
            _modifiedTag = new DataCacheTag("Modified");

            // Make sure the region is created
            _persistantCache.CreateRegion(_cacheRegion);

            // Use our lock factory
            var lockNamespace = cacheRegion + "::Locks::";
            SetLockFactory(new AzureDataCacheLockFactory(lockNamespace, _cacheRegion, persistantCache));
        }
开发者ID:ajorkowski,项目名称:AzureDataCacheDirectory,代码行数:16,代码来源:AzureDataCacheDirectory.cs

示例4: AzureCacheClient

        public AzureCacheClient(DataCache cache, string region, TimeSpan? expirationTime) {
            _logger = LoggerProvider.LoggerFor(typeof(AzureCacheClient));
            _cache = cache;
            _region = region ?? DefaultRegion;
            // Azure Cache supports only alphanumeric strings for regions, but
            // NHibernate can get a lot more creative than that. Remove all non
            // alphanumering characters from the region, and append the hash code
            // of the original string to mitigate the risk of two distinct original
            // region strings yielding the same transformed region string.
            _regionAlphaNumeric = new String(Array.FindAll(_region.ToCharArray(), Char.IsLetterOrDigit)) + _region.GetHashCode().ToString(CultureInfo.InvariantCulture);
            _expirationTime = expirationTime;

            _cache.CreateRegion(_regionAlphaNumeric);

            //_lockHandleDictionary = new ConcurrentDictionary<object, DataCacheLockHandle>();
            //_lockTimeout = TimeSpan.FromSeconds(30);

            if (_logger.IsDebugEnabled) {
                _logger.DebugFormat("Created an AzureCacheClient for region '{0}' (original region '{1}').", _regionAlphaNumeric, _region);
            }
        }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:21,代码来源:AzureCacheClient.cs

示例5: CreateRegion

 /// <summary>
 /// Creates an AppFabric cache region.
 /// </summary>
 /// <param name="cache">The data cache [client] to use to create the cache region.</param>
 /// <param name="regionName">The name of the AppFabric cache region to create.</param>
 /// <param name="callback">A call back to call once the region has been created.</param>
 private void CreateRegion(DataCache cache, string regionName, Action<bool> callback)
 {
     try
     {
         callback(cache.CreateRegion(regionName));
     }
     catch (DataCacheException ex)
     {
         if (ex.ErrorCode == DataCacheErrorCode.RegionAlreadyExists)
             callback(false);
         else
         {
             throw new CacheException(ex);
         }
     }
 }
开发者ID:ianfnelson,项目名称:NHibernate.Caches.AppFabric,代码行数:22,代码来源:AppFabricCacheAdapter.cs

示例6: ActivateOptions

        public override void ActivateOptions()
        {
            base.ActivateOptions();

            try
            {
                DataCacheFactory factory;
                if (this.Hosts.Count != 0)
                {
                    LogLog.Debug(declaringType, "Activating host options");
                    DataCacheFactoryConfiguration config = new DataCacheFactoryConfiguration();
                    List<DataCacheServerEndpoint> servers = new List<DataCacheServerEndpoint>();
                    for (int i = 0; i < this.Hosts.Count; i++)
                    {
                        servers.Add(new DataCacheServerEndpoint(this.Hosts[i].Host, this.Hosts[i].Port));
                    }
                    config.Servers = servers;
                    factory = new DataCacheFactory(config);
                }
                else
                {
                    LogLog.Debug(declaringType, "No host options detected, using default cache factory");
                    factory = new DataCacheFactory();
                }
                _Cache = factory.GetCache(this.CacheName);

                //config region exists before we attempt to write to it.
                _Cache.CreateRegion(this.RegionName);

                var obj = _Cache.Get(Shared.LAST_PUSHED_KEY_KEY, this.RegionName);
                if (obj == null)
                {
                    _Cache.Put(Shared.LAST_PUSHED_KEY_KEY, "0", this.RegionName);
                }
            }
            catch (Exception ex)
            {
                this.ErrorHandler.Error("Could not create connection to App Fabric", ex);
                this._Cache = null;
            }
        }
开发者ID:edwinf,项目名称:AppFabricAppender,代码行数:41,代码来源:BufferedAppFabricAppender.cs

示例7: AzureCacheStore

 public AzureCacheStore(string cacheName)
 {
     cache = new DataCache(cacheName);
     cache.CreateRegion(CacheRegion);
 }
开发者ID:tugberkugurlu,项目名称:CacheCow,代码行数:5,代码来源:AzureCacheStore.cs

示例8: ConnectCache

 private static void ConnectCache(string cacheName, DataCacheFactoryConfiguration config)
 {
     try
     {
         var factory = new DataCacheFactory(config);
         _cache = factory.GetCache(cacheName);
         _cache.CreateRegion(_cacheRegion);
         _cacheConnected.Set();
     }
     catch
     {
         ;
     }
 }
开发者ID:itsjason,项目名称:Stache-Cache,代码行数:14,代码来源:RemoteCache.cs

示例9: PrepareClient

        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;
            }
        }
开发者ID:randomyed,项目名称:SobekCM-Web-Application,代码行数:56,代码来源:AppFabric_Manager.cs

示例10: AzureCachingEntityTagStore

 public AzureCachingEntityTagStore(DataCache cache, string regionName)
 {
     _regionName = regionName;
     _cache = cache;
     _cache.CreateRegion(regionName);
 }
开发者ID:yyf919,项目名称:CacheCow,代码行数:6,代码来源:AzureCachingEntityTagStore.cs

示例11: CreateRegion

        /// <summary>
        /// Creates an AppFabric cache region.
        /// </summary>
        /// <param name="cache">The data cache [client] to use to create the cache region.</param>
        /// <param name="regionName">The name of the AppFabric cache region to create.</param>
        /// <param name="callback">A call back to call once the region has been created.</param>
        private void CreateRegion(DataCache cache, string regionName, Action<bool> callback)
        {

            if (log.IsDebugEnabled)
            {
                log.DebugFormat("Creating cache region {1}", regionName);
            }

            try
            {
                callback(cache.CreateRegion(regionName));
            }
            catch (DataCacheException ex)
            {
                if (ex.ErrorCode == DataCacheErrorCode.RegionAlreadyExists)
                    callback(false);
                else
                {
                    throw new CacheException(ex);
                }
            }
        }
开发者ID:SathishN,项目名称:NHibernate.Caches.AppFabric,代码行数:28,代码来源:AppFabricCacheAdapter.cs


注:本文中的DataCache.CreateRegion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。