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


C# DataCache类代码示例

本文整理汇总了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;
        }
开发者ID:jrcavallaro,项目名称:DotNet,代码行数:35,代码来源:CashUtil.cs

示例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;
        }
开发者ID:kirpasingh,项目名称:MicrosoftAzureTrainingKit,代码行数:32,代码来源:VideoService.cs

示例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;
        }
开发者ID:LloydPickering,项目名称:SignalR.AppFabric,代码行数:7,代码来源:DependencyResolverExtensions.cs

示例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;
        }
开发者ID:CuneytKukrer,项目名称:TestProject,代码行数:33,代码来源:Program.cs

示例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;
 }
开发者ID:rid50,项目名称:PSCBioOffice,代码行数:13,代码来源:FillAppFabricCache.cs

示例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;
            });
        }
开发者ID:kanujhun,项目名称:orchard,代码行数:28,代码来源:AzureOutputCacheStorageProvider.cs

示例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);
            }
        }
开发者ID:BernieCook,项目名称:AzureCache,代码行数:34,代码来源:WorkerRole.cs

示例8: Main

 internal static void Main(string[] args)
 {
     DataCache svr = new DataCache();
     svr.Init(args);
     svr.Loop();
     svr.Release();
 }
开发者ID:dreamanlan,项目名称:CSharpGameFramework,代码行数:7,代码来源:DataCache.cs

示例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);
            }
        }
开发者ID:BGCX261,项目名称:zhoulijinrong-svn-to-git,代码行数:34,代码来源:Global.asax.cs

示例10: LookUp

 public LookUp(ArrayList fingerList, int gender, byte[] probeTemplate, DataCache cache, CancellationToken ct)
 {
     _fingerList     = fingerList;
     _gender         = gender;
     _probeTemplate  = probeTemplate;
     _cache          = cache;
     _ct             = ct;
 }
开发者ID:rid50,项目名称:PSCBioOfficeWeb,代码行数:8,代码来源:LookUp.cs

示例11: TestGetInvalid

 public void TestGetInvalid ()
 {
     RunAsync (async delegate {
         var cache = new DataCache ();
         var data = await cache.GetAsync<WorkspaceData> (Guid.NewGuid ());
         Assert.IsNull (data);
     });
 }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:8,代码来源:DataCacheTest.cs

示例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);
 }
开发者ID:VDBBjorn,项目名称:toggl_mobile,代码行数:8,代码来源:DataCacheTest.cs

示例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);
		}
开发者ID:Kjubo,项目名称:xms.core,代码行数:8,代码来源:DistributeCache.cs

示例14: AzureCacheStore

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

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

示例15: ShouldReturnNotNullInstances

            public void ShouldReturnNotNullInstances()
            {
                var cache = new DataCache();

                Assert.NotNull(cache.Empty);
                Assert.NotNull(cache.MonitorConfigs);
                Assert.NotNull(cache.MonitorInfo);
            }
开发者ID:Zocdoc,项目名称:ZocMon,代码行数:8,代码来源:TestForDataCache.cs


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