.net cache

原文链接: http://www.cnblogs.com/huangwj21/archive/2010/10/22/1858374.html

1. why use cache

can increase performance by storing memory data that is access frequently and that requires signficant processing time to create.

2. application cache

the application cache provide a programmatic way for you to store arbitaray data in memory using key/value pairs.

3.diifference between application cache and application state

The cache is volatile but the application state is statice, the cache is not stored in memory for the life of application.the cache can be remove when the data is expire or become invalidated, or when the memory runs low.

4.page output cache

stores the contents of a processed asp.net page in memory. use when a page don't change often and require significant processing to create.

two modles: full page cache and partical page cache.

5.automatic data removal

three statements: 1.scavenge 2.expired 3 dependency changed

扫描二维码关注公众号,回复: 6779258 查看本文章

6 about scavenge

scavenge is the process of deleting items from cache when memory is scarce. Items are delete when they have not been accessed in some time or when items are mark as low priority when add to cache. ASP.NET uses the CacheItemPriority to determine which items to scavenge first.

7.Expiration

we can set expire time for cache when added.there are two types of expiration

a.sliding expiration: specified how long after an item was last accessed that it expires.for example , you can set an item to expire after 20 mins after it was last accessed in the cache.

b.absolute expiration: specified that an item expires at a set time, regardless of how often it accessed. eg. you can set an item to expire at 6:00 pm or after four hours.

8. dependency

configure an item's lifetime in the cache be dependent on other application elements such as files or databases. when the element that a cache item depends on changes, asp.net removes the item from the cache

转载于:https://www.cnblogs.com/huangwj21/archive/2010/10/22/1858374.html

猜你喜欢

转载自blog.csdn.net/weixin_30339457/article/details/94963589