本文整理汇总了C#中DataCache类的典型用法代码示例。如果您正苦于以下问题:C# DataCache类的具体用法?C# DataCache怎么用?C# DataCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataCache类属于命名空间,在下文中一共展示了DataCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCache
public static DataCache GetCache()
{
if (_cache != null)
{
return _cache;
}
//Define Array for 1 Cache Host
var servers = new List<DataCacheServerEndpoint>(1);
//Specify Cache Host Details
// Parameter 1 = host name
// Parameter 2 = cache port number
servers.Add(new DataCacheServerEndpoint("DevMongoDB2", 22233));
//Create cache configuration
var configuration = new DataCacheFactoryConfiguration
{
Servers = servers,
LocalCacheProperties = new DataCacheLocalCacheProperties()
};
//Disable tracing to avoid informational/verbose messages on the web page
DataCacheClientLogManager.ChangeLogLevel(System.Diagnostics.TraceLevel.Off);
//Pass configuration settings to cacheFactory constructor
//_factory = new DataCacheFactory(configuration);
_factory = new DataCacheFactory(configuration: configuration);
//Get reference to named cache called "default"
_cache = _factory.GetCache("default");
return _cache;
}
示例2: CreateVideoAsync
public async Task<Video> CreateVideoAsync(string title, string description, string name, string type, Stream dataStream)
{
// Create an instance of the CloudMediaContext
var mediaContext = new CloudMediaContext(
CloudConfigurationManager.GetSetting("MediaServicesAccountName"),
CloudConfigurationManager.GetSetting("MediaServicesAccountKey"));
// Create the Media Services asset from the uploaded video
var asset = mediaContext.CreateAssetFromStream(name, title, type, dataStream);
// Get the Media Services asset URL
var videoUrl = mediaContext.GetAssetVideoUrl(asset);
// Launch the smooth streaming encoding job and store its ID
var jobId = mediaContext.ConvertAssetToSmoothStreaming(asset, true);
var video = new Video
{
Title = title,
Description = description,
SourceVideoUrl = videoUrl,
JobId = jobId
};
this.context.Videos.Add(video);
await this.context.SaveChangesAsync();
var cache = new DataCache();
cache.Remove("videoList");
return video;
}
示例3: UseAppFabric
public static IDependencyResolver UseAppFabric(this IDependencyResolver resolver, String eventKey, TimeSpan cacheRecycle, DataCache dc)
{
var bus = new Lazy<AppFabricMessageBus>(() => new AppFabricMessageBus(resolver, eventKey, cacheRecycle, dc));
resolver.Register(typeof(IMessageBus), () => bus.Value);
return resolver;
}
示例4: GetCache
public static DataCache GetCache()
{
if (_cache != null)
return _cache;
//Define Array for 1 Cache Host
List<DataCacheServerEndpoint> servers = new List<DataCacheServerEndpoint>(1);
//Specify Cache Host Details
// Parameter 1 = host name
// Parameter 2 = cache port number
servers.Add(new DataCacheServerEndpoint("192.168.1.31", 22233));
//Create cache configuration
DataCacheFactoryConfiguration configuration = new DataCacheFactoryConfiguration();
//Set the cache host(s)
configuration.Servers = servers;
//Set default properties for local cache (local cache disabled)
configuration.LocalCacheProperties = new DataCacheLocalCacheProperties();
//Disable tracing to avoid informational/verbose messages on the web page
DataCacheClientLogManager.ChangeLogLevel(System.Diagnostics.TraceLevel.Off);
//Pass configuration settings to cacheFactory constructor
_factory = new DataCacheFactory(configuration);
//Get reference to named cache called "default"
_cache = _factory.GetCache("default");
return _cache;
}
示例5: FillAppFabricCache
//static FillAppFabricCache()
//{
// DataCacheFactory factory = new DataCacheFactory();
// _cache = factory.GetCache("default");
// //Debug.Assert(_cache == null);
//}
public FillAppFabricCache(CancellationToken ct, DataCache cache, byte[] probeTemplate, ArrayList fingerList)
{
_ct = ct;
_cache = cache;
_probeTemplate = probeTemplate;
_fingerList = fingerList;
}
示例6: AzureOutputCacheStorageProvider
public AzureOutputCacheStorageProvider(ShellSettings shellSettings, IAzureOutputCacheHolder cacheHolder) {
var region = shellSettings.Name;
// Azure Cache supports only alphanumeric strings for regions, but Orchard supports some
// non-alphanumeric characters in tenant names. 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);
_cache = cacheHolder.TryGetDataCache(() => {
CacheClientConfiguration cacheConfig;
try {
cacheConfig = CacheClientConfiguration.FromPlatformConfiguration(shellSettings.Name, Constants.OutputCacheSettingNamePrefix);
cacheConfig.Validate();
}
catch (Exception ex) {
throw new Exception(String.Format("The {0} configuration settings are missing or invalid.", Constants.OutputCacheFeatureName), ex);
}
var cache = cacheConfig.CreateCache();
cache.CreateRegion(_regionAlphaNumeric);
return cache;
});
}
示例7: Run
public override void Run()
{
DataCache dataCache = null;
var roleInstanceId = RoleEnvironment.CurrentRoleInstance.Id;
while (true)
{
if (dataCache == null)
{
try
{
dataCache = new DataCache("default");
}
catch (DataCacheException)
{
Thread.Sleep(1000);
continue;
}
}
var value = dataCache.Get("Tim");
if (value != null)
{
EventLog.WriteEntry(
string.Concat("AzureCache ", roleInstanceId),
string.Concat("Tim = ", (string)value));
// Uncomment for Azure testing.
// dataCache.Put("Tim", string.Concat((string)value, RoleEnvironment.CurrentRoleInstance.Id));
}
Thread.Sleep(2000);
}
}
示例8: Main
internal static void Main(string[] args)
{
DataCache svr = new DataCache();
svr.Init(args);
svr.Loop();
svr.Release();
}
示例9: Application_Start
protected void Application_Start(object sender, EventArgs e)
{
String l_strDataSource = OAConfig.GetConfig("数据库", "DataSource");
String l_strDatabase = OAConfig.GetConfig("数据库", "DataBase");
String l_strUserId = OAConfig.GetConfig("数据库", "uid");
String l_strPassword = OAConfig.GetConfig("数据库", "pwd");
//初始化数据库连接
if (!Entity.InitDB(ConstString.Miscellaneous.DATA_BASE_TYPE, l_strDataSource, l_strDatabase, l_strUserId, l_strPassword, 30))
{
throw new Exception("数据库连接错误");
}
SQLHelper.InitDB1(OAConfig.GetConfig("数据库", "ADIMSqlServer"));
SQLHelper.InitDB2(OAConfig.GetConfig("数据库", "AgilePointSqlServer"));
//自动阅知
AutoRead.Instance.TimerStart();
//自动迁移旧数据
AutoBackup.Instance.TimerStart();
//把XML文件加载到缓存中
string strPath = AppDomain.CurrentDomain.BaseDirectory + @"Config\SelectGroup.xml";
if (!string.IsNullOrEmpty(strPath))
{
XmlDocument doc = new XmlDocument();
doc.Load(strPath);
DataCache cache = new DataCache();
cache.ExpireTime = 1440;
cache.CacheName = "SelectGroup";
cache.CacheItemName = "SelectGroupItem";
cache.SetCache(doc);
}
}
示例10: LookUp
public LookUp(ArrayList fingerList, int gender, byte[] probeTemplate, DataCache cache, CancellationToken ct)
{
_fingerList = fingerList;
_gender = gender;
_probeTemplate = probeTemplate;
_cache = cache;
_ct = ct;
}
示例11: TestGetInvalid
public void TestGetInvalid ()
{
RunAsync (async delegate {
var cache = new DataCache ();
var data = await cache.GetAsync<WorkspaceData> (Guid.NewGuid ());
Assert.IsNull (data);
});
}
示例12: TestTryGetInvalid
public void TestTryGetInvalid ()
{
var cache = new DataCache ();
WorkspaceData data;
var success = cache.TryGetCached (Guid.NewGuid (), out data);
Assert.IsFalse (success);
Assert.IsNull (data);
}
示例13: DistributeCache
internal DistributeCache(DataCache dataCache, string cacheName, string regionName)
{
this.dataCache = dataCache;
this.cacheName = cacheName;
this.regionName = regionName;
this.asyncUpdateInterval = CacheSettings.Instance.GetAsyncUpdateInterval(cacheName, regionName);
}
示例14: AzureCacheStore
public AzureCacheStore(DataCache cache, string cacheRegion)
{
_cacheRegion = cacheRegion;
_cache = cache;
if (!string.IsNullOrEmpty(_cacheRegion))
_cache.CreateRegion(_cacheRegion);
}
示例15: ShouldReturnNotNullInstances
public void ShouldReturnNotNullInstances()
{
var cache = new DataCache();
Assert.NotNull(cache.Empty);
Assert.NotNull(cache.MonitorConfigs);
Assert.NotNull(cache.MonitorInfo);
}