本文整理汇总了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);
}
示例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.
}
}
示例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));
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
}
示例7: AzureCacheStore
public AzureCacheStore(string cacheName)
{
cache = new DataCache(cacheName);
cache.CreateRegion(CacheRegion);
}
示例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
{
;
}
}
示例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;
}
}
示例10: AzureCachingEntityTagStore
public AzureCachingEntityTagStore(DataCache cache, string regionName)
{
_regionName = regionName;
_cache = cache;
_cache.CreateRegion(regionName);
}
示例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);
}
}
}