本文整理汇总了C#中System.Web.Caching.Cache类的典型用法代码示例。如果您正苦于以下问题:C# Cache类的具体用法?C# Cache怎么用?C# Cache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cache类属于System.Web.Caching命名空间,在下文中一共展示了Cache类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TryFindViewFromViewModel
protected string TryFindViewFromViewModel(Cache cache, object viewModel)
{
if (viewModel != null)
{
var viewModelType = viewModel.GetType();
var cacheKey = "ViewModelViewName_" + viewModelType.FullName;
var cachedValue = (string)cache.Get(cacheKey);
if (cachedValue != null)
{
return cachedValue != NoVirtualPathCacheValue ? cachedValue : null;
}
while (viewModelType != typeof(object))
{
var viewModelName = viewModelType.Name;
var namespacePart = viewModelType.Namespace.Substring("FODT.".Length);
var virtualPath = "~/" + namespacePart.Replace(".", "/") + "/" + viewModelName.Replace("ViewModel", "") + ".cshtml";
if (Exists(virtualPath) || VirtualPathProvider.FileExists(virtualPath))
{
cache.Insert(cacheKey, virtualPath, null /* dependencies */, Cache.NoAbsoluteExpiration, _defaultCacheTimeSpan);
return virtualPath;
}
viewModelType = viewModelType.BaseType;
}
// no view found
cache.Insert(cacheKey, NoVirtualPathCacheValue, null /* dependencies */, Cache.NoAbsoluteExpiration, _defaultCacheTimeSpan);
}
return null;
}
开发者ID:jdaigle,项目名称:FriendsOfDT,代码行数:29,代码来源:ViewModelSpecifiedViewEngine.cs
示例2: ReadJsonFromFileAndCache
public async static Task<List<Dictionary<string, object>>> ReadJsonFromFileAndCache(string pathToFile, Cache cache)
{
string jsonString = null;
Dictionary<string, List<Dictionary<string, object>>> jsonData = null;
try
{
jsonString = await Task.Run(() => ReadJsonDataFromFile(pathToFile));
jsonData = await Task.Run(() => JsonHelper.Parse(jsonString));
}
catch
{
jsonString = String.Empty;
}
List<Dictionary<string, object>> result = new List<Dictionary<string, object>>();
foreach(var list in jsonData.Values)
{
result.AddRange(list);
}
CacheJson(cache, "jsonData", result, pathToFile);
return result;
}
开发者ID:Dmitry-Karnitsky,项目名称:Epam_ASP.NET_Courses,代码行数:26,代码来源:JsonHelper.cs
示例3: GetDummyData
//An example of caching.
public static IEnumerable<string> GetDummyData(Cache cache)
{
var action = new Func<IEnumerable<string>>(() => { return new List<string>() { "foo", "bar", "lipsum" }; });
var things = ((IEnumerable<string>)BaseCache.GetInsertCacheItem(cache, BaseCacheNames.DummyData.ToString(), action, null));
return things;
}
开发者ID:erasmosud,项目名称:sharpbox,代码行数:8,代码来源:CacheCollection.cs
示例4: Initialize
/// <summary>
/// Initializes this cache provider.
/// </summary>
public void Initialize(CacheProviderInitializationArgs args)
{
// This may seem odd, but using the ASP.NET cache outside of an ASP app
// is perfectly ok, according to this MSDN article:
// http://msdn.microsoft.com/en-us/library/ms978500.aspx
_cache = HttpRuntime.Cache;
}
开发者ID:nhannd,项目名称:Xian,代码行数:10,代码来源:DefaultCacheProvider.cs
示例5: CacheEntry
internal CacheEntry (Cache objManager, string strKey, object objItem,CacheDependency objDependency,
CacheItemRemovedCallback eventRemove, DateTime dtExpires, TimeSpan tsSpan,
long longMinHits, bool boolPublic, CacheItemPriority enumPriority )
{
if (boolPublic)
_enumFlags |= Flags.Public;
_strKey = strKey;
_objItem = objItem;
_objCache = objManager;
_onRemoved += eventRemove;
_enumPriority = enumPriority;
_ticksExpires = dtExpires.ToUniversalTime ().Ticks;
_ticksSlidingExpiration = tsSpan.Ticks;
// If we have a sliding expiration it overrides the absolute expiration (MS behavior)
// This is because sliding expiration causes the absolute expiration to be
// moved after each period, and the absolute expiration is the value used
// for all expiration calculations.
if (tsSpan.Ticks != Cache.NoSlidingExpiration.Ticks)
_ticksExpires = DateTime.UtcNow.AddTicks (_ticksSlidingExpiration).Ticks;
_objDependency = objDependency;
if (_objDependency != null)
// Add the entry to the cache dependency handler (we support multiple entries per handler)
_objDependency.Changed += new CacheDependencyChangedHandler (OnChanged);
_longMinHits = longMinHits;
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:29,代码来源:CacheEntry.cs
示例6: LessCssHttpHandler
public LessCssHttpHandler(
Cache cache,
IVirtualFileSystemWrapper virtualFileSystemWrapper,
AssetHandlerSettings assetHandlerConfig)
: base(cache, virtualFileSystemWrapper, assetHandlerConfig)
{
}
开发者ID:boatengfrankenstein,项目名称:SmartStoreNET,代码行数:7,代码来源:LessCssHttpHandler.cs
示例7: Dump
public List<Node> Dump(Cache session)
{
return session.Cast<DictionaryEntry>()
.OrderBy(x => x.Key)
.Select(x => Process("item", (string)x.Key, x.Value, 0))
.ToList();
}
开发者ID:ByteCarrot,项目名称:Aspy,代码行数:7,代码来源:ObjectDumper.cs
示例8: GetService
public static AggregationCategorizationService GetService(Cache cache, String userId)
{
try
{
if (cache["AggCatService_" + userId] == null)
{
string certificateFile = System.Configuration.ConfigurationManager.AppSettings["PrivateKeyPath"];
string password = System.Configuration.ConfigurationManager.AppSettings["PrivateKeyPassword"];
X509Certificate2 certificate = new X509Certificate2(certificateFile, password);
string consumerKey = System.Configuration.ConfigurationManager.AppSettings["ConsumerKey"];
string consumerSecret = System.Configuration.ConfigurationManager.AppSettings["ConsumerSecret"];
string issuerId = System.Configuration.ConfigurationManager.AppSettings["SAMLIdentityProviderID"];
SamlRequestValidator samlValidator = new SamlRequestValidator(certificate, consumerKey, consumerSecret, issuerId, userId);
ServiceContext ctx = new ServiceContext(samlValidator);
cache.Add("AggCatService_" + userId, new AggregationCategorizationService(ctx), null, DateTime.Now.AddMinutes(50),
Cache.NoSlidingExpiration, CacheItemPriority.High, null);
}
return (AggregationCategorizationService)cache["AggCatService_" + userId];
}
catch (Exception ex)
{
throw new Exception("Unable to create AggCatService: " + ex.Message);
}
}
开发者ID:tarandhupar,项目名称:IPP_Sample_Code,代码行数:28,代码来源:AggCatService.cs
示例9: BritBoxingTwitterInfo
public BritBoxingTwitterInfo(Cache cache, TwitterService service)
{
_cache = cache;
_service = service;
UpdateContent();
}
开发者ID:elmo61,项目名称:BritBoxing,代码行数:7,代码来源:BritBoxingTwitterInfo.cs
示例10: DotNetCacheManager
/// <summary>
/// 构造函数
/// </summary>
public DotNetCacheManager()
{
if (HttpContext.Current != null)
{
cache = HttpContext.Current.Cache;
}
}
开发者ID:xqgzh,项目名称:Z,代码行数:10,代码来源:DotNetCacheManager.cs
示例11: SiteCache
static SiteCache()
{
DayFactor = 17280;
HourFactor = 720;
MinuteFactor = 12;
Factor = 5;
_cache = HttpRuntime.Cache;
}
开发者ID:wangyi3330,项目名称:wpfTest,代码行数:8,代码来源:SiteCache.cs
示例12: Scheduler
/// <summary>
/// Initializes a new instance of the <see cref="Scheduler"/> class.
/// </summary>
/// <param name="tasks">The tasks.</param>
/// <param name="internalCheckInterval">The internal check interval (in seconds).</param>
public Scheduler(SchedulerTask[] tasks, int internalCheckInterval = 120)
{
_tasks = tasks;
_internalCheckInterval = internalCheckInterval;
_cache = HttpRuntime.Cache;
_logger = LogManager.GetLogger("SchedulerTask");
_logger.Trace("Scheduler created.");
}
开发者ID:vlko,项目名称:vlko,代码行数:13,代码来源:Scheduler.cs
示例13: HttpListenerContextAdapter
public HttpListenerContextAdapter(HttpListenerContext context, string virtualPath, string physicalPath)
{
this.request = new HttpListenerRequestAdapter(context.Request, virtualPath, MakeRelativeUriFunc(context.Request.Url, virtualPath));
this.response = new HttpListenerResponseAdapter(context.Response);
this.server = new ConcoctHttpServerUtility(physicalPath);
this.cache = new Cache();
this.session = new HttpListenerSessionState();
}
开发者ID:drunkcod,项目名称:Concoct,代码行数:8,代码来源:HttpListenerContextAdapter.cs
示例14: SysCache
public SysCache(string region, IDictionary<string, string> properties)
{
this.region = region;
this.cache = HttpRuntime.Cache;
this.Configure(properties);
this.rootCacheKey = this.GenerateRootCacheKey();
this.StoreRootCacheKey();
}
开发者ID:gongzunpan,项目名称:infrastructure,代码行数:8,代码来源:SysCache.cs
示例15: FieldCacheFacade
public FieldCacheFacade()
{
string xmlFile = HttpContext.Current.Server.MapPath("~/schemamapping.xml");
CacheDependency xmlDependency = new CacheDependency(xmlFile);
Cache cache = new Cache();
cache.Insert("", null, xmlDependency);
}
开发者ID:atian15,项目名称:peisong-expert,代码行数:8,代码来源:FieldCacheFacade.cs
示例16: CacheService
public CacheService(Cache cache)
{
if (cache == null)
{
throw new ArgumentNullException("cache");
}
_cache = cache;
}
开发者ID:bhaktapk,项目名称:com-prerit,代码行数:9,代码来源:CacheService.cs
示例17: ServiceCache
/// <summary>
/// Initializes a new instance of the <see cref="ServiceCache"/> class.
/// </summary>
public ServiceCache()
{
m_cache = HttpRuntime.Cache; // works in and out of the ASP.NET process
if (m_cache == null)
{
throw new InvalidOperationException(Resources.Global.UnableToInitializeCache);
}
}
开发者ID:dstarosta,项目名称:GitProjects,代码行数:12,代码来源:ServiceCache.cs
示例18: BaseCache
public BaseCache(string _logFolder)
: base(_logFolder)
{
//
// TODO: 在此处添加构造函数逻辑
//
this.cache = HttpContext.Current.Cache;
iCacheTimeMinute = CstHalfHour;
}
开发者ID:0jpq0,项目名称:Scut,代码行数:9,代码来源:BaseCache.cs
示例19: SetCache
private void SetCache()
{
lock(Lock)
{
if (HttpContext.Current == null || _cache != null)
return;
_cache = HttpContext.Current.Cache;
}
}
开发者ID:jjchiw,项目名称:Nancy.LightningCache,代码行数:9,代码来源:WebCacheStore.cs
示例20: ClearCache
public static void ClearCache(Cache cache)
{
var itms = GetAllUsers(cache);
foreach (var itm in itms)
{
var email = itm.Value["email"].ReadAs<string>();
cache.Remove(email);
}
}
开发者ID:axshon,项目名称:HTML-5-Ellipse-Tours,代码行数:9,代码来源:CacheRepo.cs
注:本文中的System.Web.Caching.Cache类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论