当前位置:网站首页>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" };
边栏推荐
- Motor monitoring system based on MCGS and stm32
- 2021-04-28
- Logstash discards log data that does not match the file name exactly
- Web學習之TypeScript
- Binary sort tree
- Apache foundation officially announced Apache inlong as a top-level project
- Solve STM32 operation μ Solution to sudden failure of task scheduling in c/os-ii system
- QT custom QSlider with cursor
- Spark log analysis
- Modelsim simulation FFT core cannot be simulated solution (qsys)
猜你喜欢
![Final review [machine learning]](/img/63/d617a95592b1499cff0161bd5c3e9e.png)
Final review [machine learning]

Ssl/tls, symmetric and asymmetric encryption, and tlsv1.3

Compile the telegraph desktop side (tdesktop) using vs2022

jarvisoj_level2_x64

Leetcode 513. Find the value in the lower left corner of the tree

Performance leads the cloud native database market! Intel and Tencent jointly build cloud technology ecology

关于HC-12无线射频模块使用

Web学习之TypeScript

Law and self-regulation in the meta universe

Is camkiia the same as gcamp6f?
随机推荐
Why is it best to use equals for integer comparisons
Wireshark's analysis of IMAP packet capturing
Qt之自定义带游标的QSlider
使用VS2022編譯Telegram桌面端(tdesktop)
sqlserver 区分字符串中字母大小写
关于HC-12无线射频模块使用
Anaconda beginner's notes
Ssl/tls, symmetric and asymmetric encryption, and tlsv1.3
Logstash discards log data that does not match the file name exactly
Mining pit record of modified field information in Dameng database
【图像检测】基于高斯过程和Radon变换实现血管跟踪和直径估计附matlab代码
Why do we need to make panels and edges in PCB production
mtb13_ Perform extract_ blend_ Super{candidate (primaryalternate) \u unique (nullable filtering \foreign\index\granulati
安卓缓存使用工具类
Kylin
Idea view unit test coverage
Camkiia et gcamp6f sont - ils les mêmes?
C IO stream (II) extension class_ Packer
Px4 system terminal for pixhawk
下载安装Flume