Isline Framework Series Xi.--httpcontentprovider Access cache

Source: Internet
Author: User
Tags bool httpcontext microsoft sql server microsoft sql server 2005 set time

Today we're going to introduce the IsLine.HttpContent.HttpContentProvider namespace:

This provider mainly encapsulates the operation of caching, session, and Cooike, which has three main classes: Cookieprovider, Sessionprovider, Cacheprovider.

About constraints

These three class libraries unify the Icapability interface, icapability inherit from Ibasecapability interface, ibasecapability standardize the Httpcontentprovider basic ability, And Icapability is an extension of the basic capabilities, as follows:

Code

namespace IsLine.HttpContent.HttpContentProvider
{
   public interface IBaseCapability
   {
     bool Remove(string Name);
     bool IsExit(string Name);
   }
   public interface ICapability : IBaseCapability
   {
     object GetContent(string Name);
     bool UpdateContent(string Name, object value);
   }
}

It can be seen that the interface mainly constrains how to delete, obtain and update an object, that is, constraining the session, cookies, cache behavior.

Cacheprovider class

First take a look at the cache operation, Cacheprovider supports. NET two types of cache: Run-time cache (Httpruntime.cache) and Context cache (HttpContext.Current.Cache), What's the difference between these two kinds of cache? Here is a simple explanation:

Httpruntime.cache is application level, and HttpContext.Current.Cache is only valid for current Web page requests. In other words, HttpRuntime cache all Web and non-web programs can be invoked, while HttpContext is only available on the web.

The data in the cache is volatile, the data is not stored in memory throughout the application lifecycle, and the cache is managed by ASP.net, which removes items from the cache when the item expires, is invalid, or is out of memory. You can also configure the application cache to notify the application when an item is removed. So, you don't know when the cache will fail, even if you've already configured the dependencies.

There are 2 types of expiration for caching:

Expiration type Description
Sliding window Specifies how long an item has expired since the last time it was accessed.
Absolute expiration Specifies that an item expires at a set time, regardless of the frequency of access.

You can configure the lifetime of an item in the cache to depend on other application elements, such as a file or database. When an element that is dependent on a cached item changes, ASP.net removes the item from the cache.

The Cacheprovider class supports the following 2 types of dependencies:

Description
File dependencies Items in the cache depend on external files. If the file is modified or deleted, the cached item is also removed.
SQL dependencies Items in the cache depend on changes to tables in Microsoft SQL Server 2005, SQL Server 2000, or SQL Server 7.0 databases. For SQL Server 2005, items in the cache can depend on a row in the table.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.