当前位置:网站首页>ASP. Net cache cache usage
ASP. Net cache cache usage
2022-06-26 00:53:00 【App Hunter】
1. Cache data temporary data
2. Set the cache
System.Web.Caching.Cache objCache = HttpRuntime.Cache;
// Unexpired cache
objCache.Insert("WEI", "158662255");
// Set up 10 Seconds cache
objCache.Insert("WEI2", "dsfsdsxs", null, DateTime.MaxValue, new TimeSpan(0,0,10), System.Web.Caching.CacheItemPriority.NotRemovable, null);
// Cache to file ( Fail to succeed )
object errorData="sdfsjcmsjcslcfmsfsl";
CacheDependency fileDependency = new CacheDependency(@"C:\Users\Administrator\source\repos\ConsoleApp1\errors.txt");
objCache.Insert("ERROR_INFO", errorData, fileDependency);
// Key value dependent cache , A modification will expire. All values of the user information contain : Number , full name , Address, etc , If the user number changes, then cache invalid , In this case , The user's basic information depends on the user number .
string[] relatedKeys = new string[1];
relatedKeys[0] = "EMP_NUM";
CacheDependency keyDependency = new CacheDependency(null, relatedKeys);
objCache["EMP_NUM"] = 5435;
objCache.Insert("EMP_NAME", "Shubhabrata", keyDependency);
objCache.Insert("EMP_ADDR", "Bhubaneswar", keyDependency);
objCache.Insert("EMP_SAL", "5555USD", keyDependency);
3. Read cache
// Read cache
System.Web.Caching.Cache objCache2 = HttpRuntime.Cache;
var ddd = objCache2["WEI"];
var ddd2 = objCache2["WEI2"];
var ddd3 = objCache2["ERROR_INFO"];
return new string[] { "value1", "value2" };
边栏推荐
- 随便画画的
- Flex & Bison 开始
- 论文中英文大小写、数字与标点的正确撰写方式
- Motor monitoring system based on MCGS and stm32
- 【图像检测】基于高斯过程和Radon变换实现血管跟踪和直径估计附matlab代码
- Chapter VI exercises (678) [microcomputer principles] [exercises]
- Msp430f5529lp official board (red) can not debug the problem
- leetcode. 14 --- longest public prefix
- QT excellent open source project 9: qtox
- Chapter V exercises (124, 678, 15, 19, 22) [microcomputer principles] [exercises]
猜你喜欢

Cloud rendering and Intel jointly create the "core" era of cloud rendering

Compile the telegraph desktop side (tdesktop) using vs2022

DPVS fullnat mode management
![Chapter V exercises (124, 678, 15, 19, 22) [microcomputer principles] [exercises]](/img/16/d67f38d32af6904a7d0be9f2e5be70.png)
Chapter V exercises (124, 678, 15, 19, 22) [microcomputer principles] [exercises]

jarvisoj_level2_x64

Web學習之TypeScript

leetcode. 14 --- longest public prefix

Why is it best to use equals for integer comparisons

Atlas200dk brush machine

Analyze the five root causes of product development failure
随机推荐
QT excellent open source project 9: qtox
Flex & Bison 开始
Chapter VI exercises (678) [microcomputer principles] [exercises]
Solve STM32 operation μ Solution to sudden failure of task scheduling in c/os-ii system
信号处理函数内必须使用可重入函数
Comprehensive introduction to Simulink solver
How product managers control the progress of product development
Web学习之TypeScript
.net使用Access 2010数据库
MySQL custom function instance
[system architecture] - what are MDA architecture, ADL and DSSA
Px4 system terminal for pixhawk
What training brings happiness
1-10Vmware构建自定义的网络架构
使用VS2022编译Telegram桌面端(tdesktop)
Logstash discards log data that does not match the file name exactly
C IO stream (I) basic concept_ Basic definition
. user. PHP website installation problems caused by INI files
Analyze the five root causes of product development failure
关于EF翻页查询数据库