In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the example analysis of ASP.NET cache in PetShop, which is very detailed and has certain reference value. Friends who are interested must finish it!
Four ASP.NET caches for PetShop
If we know enough about the hardware system of microcomputer, then we must be familiar with the term Cache. This technology, called cache memory (Cache), is introduced in CPU and motherboard chips. Because the access speed of Cache is faster than memory, the introduction of Cache can effectively solve the problem of speed mismatch between CPU and memory. The hardware system can use Cache to store the data with high probability of CPU access. When CPU needs to access these data, it can be read directly from Cache without having to access the memory with relatively slow access speed, thus improving the efficiency of CPU. The software design draws lessons from the mechanism of introducing cache in the hardware design to improve the performance of the whole system, especially for a database-driven Web application, the utilization of cache is indispensable. After all, database query may be one of the most frequently called but slowest operations in the whole Web site, and we can not be slowed down by its old legs. Caching mechanism is the accelerator to solve this defect.
4.1 Overview of ASP.NET caching
As the main product of developing Web applications under .net framework, ASP.NET takes full account of the caching mechanism. In some way, the data objects and Web pages needed by the system are stored in memory, so that when Web sites need to obtain these data, they do not need to go through tedious database connections, queries and complex logical operations, so that they can be "within reach", such as "searching for things", so as to improve the performance of the whole Web system.
ASP.NET provides two basic caching mechanisms to provide caching capabilities. One is the application cache, which allows developers to cache data or report business objects generated by the program. Another caching mechanism is the page output cache, which allows you to directly get the page stored in the cache without complicated reprocessing of the page.
The implementation principle of application caching is mundane, simply managing the cache space in memory through ASP.NET. The application data object placed in the cache is stored as a key / value pair, which makes it easy for the user to judge whether the item exists in the cache according to the key value when accessing the data item in the cache.
The life cycle of a data object placed in the cache is limited, and there is no guarantee that the data object will remain valid even throughout the life cycle of the application. ASP.NET can manage the application cache, such as removing data items when they are invalid, expired, or out of memory. In addition, the caller can define a callback method through the CacheItemRemovedCallback delegate to notify the user when the data item is removed.
In .net Framework, application caching is implemented through the System.Web.Caching.Cache class. It is a sealed class and cannot be inherited. For each application domain, create an instance of the Cache class whose life cycle is consistent with the life cycle of the application domain. We can use the Add or Insert methods to add data items to the application cache, as shown below:
Cache ["First"] = "First Item"; Cache.Insert ("Second", "Second Item")
We can also add dependencies to the application cache so that when the dependency changes, the data item can be removed from the cache:
String [] dependencies = {"Second"}; Cache.Insert ("Third", "Third Item", new System.Web.Caching.CacheDependency (null, dependencies))
Corresponding to this is the removal of data items in the cache. As mentioned earlier, ASP.NET can automatically manage the removal of items in the cache, but we can also explicitly remove related data items by writing code:
Cache.Remove ("First")
Compared with application caching, page output caching is more widely used. It can store the processed ASP.NET pages through memory, and when the client visits the page again, it can save the process of page processing, thus improving the performance of page access and the throughput of the Web server. For example, in an e-commerce site, users need to often query product information, this process will involve database access and search conditions matching, in the case of a large amount of data, such a search process is more time-consuming. At this point, the query result page obtained from the first search can be stored in the cache by using the page output cache. When the user queries for the second time, the process of data query can be saved and the response time of the page can be reduced.
Page output cache is divided into full page cache and partial page cache. We can cache the output of the Web page through the @ OutputCache directive. It mainly contains two parameters: Duration and VaryByParam. The Duration parameter is used to set the time, in seconds, for a page or control to cache. The following settings indicate that the cache is valid for 60 seconds:
As long as the expiration value set by Duration is not exceeded, it can be obtained directly in the cache when the user visits the same page or control.
Use the VaryByParam parameter to establish different caches based on the parameter values you set. For example, on a page that outputs weather forecast results, if you need to set up a cache for a TextBox control whose ID is txtCity, and its value will display the temperature of a city, we can set it as follows:
In this way, ASP.NET determines the value of the txtCity control and fetches the corresponding value from the cache only if the value entered is the same as the cache value. This effectively avoids outputting incorrect data due to different values.
The improvement in performance by using the caching mechanism is very obvious. Through the test of ACT (Application Center Test), we can find that the performance of caching is more than three times higher than that without caching.
The introduction of caching seems to be the "perfect" solution to improve performance, but "no one is perfect", and the caching mechanism also has a drawback, that is, the problem of data expiration. Once the application data or page result value changes, then within the cache validity range, the results you get will be out of date and inaccurate data. We can think about the disaster caused by the use of caching in stock systems. when you use wrong and out-of-date data to analyze the changes in the stock market, you will find that the results can be said to be "lost by an inch." it looks like a beautiful bubble, poking it with a needle and disappearing without a trace in the twinkling of an eye.
So should we ignore the hidden dangers caused by the so-called "data expiration" in order to pursue high performance? Obviously, in specific scenarios such as stock systems, where data is updated frequently, the poor performance of expired data is even more unacceptable than inefficient performance. Therefore, we need to make a tradeoff between performance and data correctness. Fortunately, .Net Framework 2.0 introduces a new caching mechanism, which makes it technically feasible for us to have both.
The custom cache dependency introduced by .net 2.0, especially the SqlCacheDependency feature based on MS-SQL Server, enables us to avoid the problem of "data expiration", which can notify the cache and remove expired data according to changes in the corresponding data in the database. In fact, SqlCacheDependency features are fully utilized in PetShop 4. 0.
4.2 SqlCacheDependency featur
The SqlCacheDependency feature is actually represented by the System.Web.Caching.SqlCacheDependency class. With this class, you can monitor a specific SQL Server database table on all supported SQL Server versions (7.0, 2000, and 2005) and create cache items that depend on that table and the rows in the table. When the data in a data table or a specific row in the table changes, the data item with dependencies is invalidated and automatically deleted from the Cache, thus ensuring that expired data is no longer retained in the cache.
Due to the release, SQL Server 2005 fully supports SqlCacheDependency features, but for SQL Server 2005 and SQL Server 2000, it is not so lucky. After all, these products appeared before. Net Framework 2.0, so it does not automatically monitor data changes in the data table and notify ASP.NET. The solution is to use the polling mechanism to poll the SQL Server database at specified intervals through a thread in the ASP.NET process to track the changes in the data.
To make SQL Server version 7. 0 or 2000 support the SqlCacheDependency feature, you need to perform the relevant configuration steps on the database server. There are two ways to configure SQL Server: using the aspnet_regsql command-line tool, or using the SqlCacheDependencyAdmin class.
4.2.1 using aspnet_regsql tools
The aspnet_regsql tool is located in the Windows\ Microsoft.NET\ Framework\ [version] folder. If you double-click the tool's execution file directly, a wizard dialog box will pop up and prompt us to complete the appropriate action:
Figure 4-1 aspnet_regsql tool
The prompt in figure 4-1 shows that the wizard is mainly used to configure SQL Server databases, such as membership,profiles, and if you want to configure SqlCacheDependency, you need to execute it on the command line. Take PetShop 4.0as an example, and the database is named MSPetShop4, then the command is:
Aspnet_regsql-S localhost-E-d MSPetShop4-ed
The following is a description of the command parameters for the tool:
-? Show the help features of the tool
-S is followed by the name of the database server or the IP address
-U is followed by the login user name of the database.
-P followed by the login password of the database
-E use this feature when using windows integrated authentication
-d followed by a parameter of which database to use SqlCacheDependency function
The-t followed parameter is which table uses the SqlCacheDependency function.
-ed allows the use of the SqlCacheDependency function on the database
-dd forbids the use of SqlCacheDependency functions on the database
-et allows SqlCacheDependency to be used on data tables
-dt forbids the use of SqlCacheDependency function on data tables
-lt lists which tables in the current database have adopted the sqlcachedependency feature.
Taking the above command as an example, it shows that the SqlCacheDependency function will be used for the database named MSPetShop4, and the SQL Server will adopt the windows integrated authentication mode. We can also execute aspnet_regsql commands on related data tables, such as:
Aspnet_regsql-S localhost-E-d MSPetShop4-t Item-et
Aspnet_regsql-S localhost-E-d MSPetShop4-t Product-et
Aspnet_regsql-S localhost-E-d MSPetShop4-t Category-et
When the above four commands are executed, the aspnet_regsql tool creates a new database table called AspNet_SqlCacheTablesForChangeNotification in the MSPetShop4 database. The data table contains three fields. The field tableName records the name of the data table to track, for example, in PetShop 4.0, the data tables to be recorded include Category, Item, and Product. The notificationCreated field records the time when the trace started. ChangeId, as a field of type int, is used to record the number of times the data in the datasheet has changed. As shown in figure 4-2:
Figure 4-2 AspNet_SqlCacheTablesForChangeNotification data sheet
In addition, executing this command will add a set of stored procedures to the MSPetShop4 database to provide ASP.NET with information about the data tables that are queried, and triggers will be added to tables that use SqlCacheDependency, corresponding to Insert, Update, Delete, and other operations related to data changes. For example, the trigger of the Product data table:
CREATE TRIGGER dbo.[Product _ AspNet_SqlCacheNotification_Trigger] ON [Product] FOR INSERT, UPDATE, DELETE AS BEGIN SET NOCOUNT ON EXEC dbo.AspNet_SqlCacheUpdateChangeIdStoredProcedure N'Product'END
Among them, AspNet_SqlCacheUpdateChangeIdStoredProcedure is one of a set of stored procedures added by the tool. When an operation such as Insert, Update, or Delete is performed on an Product data table, the trigger is activated and the AspNet_SqlCacheUpdateChangeIdStoredProcedure stored procedure is executed. The process it performs is to modify the changeId field value of the AspNet_SqlCacheTablesForChangeNotification data table:
CREATE PROCEDURE dbo.AspNet_SqlCacheUpdateChangeIdStoredProcedure @ tableName NVARCHAR AS BEGIN UPDATE dbo.AspNet_SqlCacheTablesForChangeNotification WITH (ROWLOCK) SET changeId = changeId + 1 WHERE tableName = @ tableName END GO
4.2.2 using the SqlCacheDependencyAdmin class
We can also use programming to manage the database's use of SqlCacheDependency features. This class contains five important methods:
DisableNotifications
Disable SqlCacheDependency object change notification for a specific database
DisableTableForNotifications
Disable SqlCacheDependency object change notifications for specific tables in the database
EnableNotifications
Enable SqlCacheDependency object change notification for a specific database
EnableTableForNotifications
Enable SqlCacheDependency object change notification for a specific table in the database
GetTablesEnabledForNotifications
Returns a list of all tables with SqlCacheDependency object change notification enabled
Table 4-1 main methods of the SqlCacheDependencyAdmin class
Suppose we define the following database connection string:
Const string connectionStr = "Server=localhost;Database=MSPetShop4"
Then the implementation of enabling SqlCacheDependency object change notification for the database MSPetShop4 is:
Protected void Page_Load (object sender, EventArgs e) {if (! IsPostBack) {SqlCacheDependencyAdmin.EnableNotifications (connectionStr);}}
The implementation of enabling SqlCacheDependency object change notification for the datasheet Product is:
SqlCacheDependencyAdmin.EnableTableForNotifications (connectionStr, "Product")
If you want to invoke the relevant methods shown in Table 4-1, it is important to note that the account accessing the SQL Server database must have permission to create tables and stored procedures. If you want to call the EnableTableForNotifications method, you also need to have permission to create a SQL Server trigger on the table.
Although programming gives programmers more flexibility, aspnet_regsql tools provide an easier way to configure and manage SqlCacheDependency. PetShop 4.0 adopts the approach of the aspnet_regsql tool, which compiles a batch file named InstallDatabases.cmd, which contains the execution of the aspnet_regsql tool, and through the installer to call the file to achieve the configuration of SQL Server.
4.3 implementation of ASP.NET cache in PetShop 4.0
As a B2C pet online store, PetShop needs to fully consider the user experience of visitors. If the response of the Web server is not timely due to the large amount of data, and the page and query data can not get results for a long time, it will destroy the mood of customers visiting the website. After running out of patience, they may lose this part of customers. No doubt, this is a very bad result. Therefore, when designing the architecture, the performance of the whole system is very important. However, we can't give up eating for fear of choking, because we focus on performance and ignore the correctness of the data. In PetShop 3.0 and previous versions, this problem has not been well resolved because of the limitations of ASP.NET caching. PetShop 4.0introduces the SqlCacheDependency feature, which makes the cache processing of the system much better than before.
4.3.1 CacheDependency interface
PetShop 4.0 introduces the SqlCacheDependency feature and implements the SQL Cache Invalidation technology for the caching of Category, Product and Item data tables. When the corresponding data table data is changed, the technique can remove the related items from the cache. The core of implementing this technology is the SqlCacheDependency class, which inherits the CacheDependency class. However, in order to ensure the scalability of the entire architecture, we also allow designers to create custom CacheDependency classes to extend cache dependencies. It is necessary to establish an abstract interface for CacheDependency and configure it in the web.config file.
In the namespace PetShop.ICacheDependency of PetShop 4.0, the IPetShopCacheDependency interface is defined, which contains only one interface method:
Public interface IPetShopCacheDependency {AggregateCacheDependency GetDependency ();}
AggregateCacheDependency is a new class in .net Framework 2.0 that monitors the collection of dependency objects. When any one of the dependency objects in this collection changes, the cache object corresponding to that dependency object is automatically removed.
The AggregateCacheDependency class acts as a combination of CacheDependency objects, which can associate multiple CacheDependency objects and even different types of CacheDependency objects with cached items. Because PetShop needs to establish dependencies for Category, Product, and Item data tables, the purpose of IPetShopCacheDependency's interface method GetDependency () is to return the AggregateCacheDependency object that created these dependencies.
4.3.2 CacheDependency implementation
The implementation of CacheDependency establishes the corresponding SqlCacheDependency type dependencies for Category, Product, and Item data tables, as shown in the code:
Public abstract class TableDependency: IPetShopCacheDependency {/ / This is the separator that's used in web.config protected char [] configurationSeparator = new char [] {','}; protected AggregateCacheDependency dependency = new AggregateCacheDependency (); protected TableDependency (string configKey) {string dbName = ConfigurationManager.AppSettings ["CacheDatabaseName"]; string tableConfig = ConfigurationManager.AppSettings [configKey]; string [] tables = tableConfig.Split (configurationSeparator); foreach (string tableName in tables) dependency.Add (new SqlCacheDependency (dbName, tableName));} public AggregateCacheDependency GetDependency () {return dependency;}}
The database and datasheet that need to create dependencies are configured in the web.config file, which is set up as follows:
According to the dependencies between different data tables, different data tables need to establish different dependencies, as can be seen from the value value in the configuration file. However, no matter how many dependencies are created, the behavior logic of their creation is similar, so in the design, a common class TableDependency is abstracted, and the dependency is established by establishing a constructor with parameters. Since the returned object dependency is created in the protected constructor in the implementation of the interface method GetDependency (), the implementation here can also be seen as a flexible use of the Template Method pattern. For example, Product, a subclass of TableDependency, uses the constructor of the parent class to establish the SqlCacheDependency dependency of Product and Category data tables:
Public class Product: TableDependency {public Product (): base ("ProductTableDependency") {}}
If you need to customize the CacheDependency, the way you create dependencies is different. However, both the creation of SqlCacheDependency objects and custom CacheDependency objects add these dependencies to the AggregateCacheDependency class, so we can also create special classes for custom CacheDependency, as long as we implement the IPetShopCacheDependency interface.
4.3.3 CacheDependency Factory
The Product, Category, and Item classes that inherit the abstract class TableDependency all need to create their own objects when called. Because their parent class, TableDependency, implements the interface IPetShopCacheDependency, they also indirectly implement the IPetShopCacheDependency interface, which provides a prerequisite for implementing the factory pattern.
In PetShop 4.0, configuration files and reflection techniques are still used to implement the factory pattern. In the namespace PetShop.CacheDependencyFactory, the class DependencyAccess is the factory class that creates the IPetShopCacheDependency object:
Public static class DependencyAccess {public static IPetShopCacheDependency CreateCategoryDependency () {return LoadInstance ("Category");} public static IPetShopCacheDependency CreateProductDependency () {return LoadInstance ("Product");} public static IPetShopCacheDependency CreateItemDependency () {return LoadInstance ("Item");} private static IPetShopCacheDependency LoadInstance (string className) {string path = ConfigurationManager.AppSettings ["CacheDependencyAssembly"]; string fullyQualifiedClass = path + "." + className; return (IPetShopCacheDependency) Assembly.Load (path) .CreateInstance (fullyQualifiedClass);}}
The implementation of the entire factory pattern is shown in figure 4-3:
Figure 4-3 CacheDependency Factory
Although the DependencyAccess class creates classes Category, Product, and Item that implement the IPetShopCacheDependency interface, the purpose of introducing the IPetShopCacheDependency interface is to obtain objects of type AggregateCacheDependency that create dependencies. We can call the object's interface method GetDependency (), as shown below:
AggregateCacheDependency dependency = DependencyAccess.CreateCategoryDependency () .GetDependency ()
For the convenience of the caller, it seems that we can improve the DependencyAccess class by changing the original CreateCategoryDependency () method to create an object of type AggregateCacheDependency.
However, this disrupts the responsibility of DependencyAccess as a factory class, and the behavior of creating an IPetShopCacheDependency interface object can still be called by the caller, so it is still necessary to keep the original DependencyAccess class.
In the design of PetShop 4.0, the Facade pattern is introduced to make it easier for callers to obtain AggregateCacheDependency type objects.
4.3.4 introduction of Facade mode
Using the Facade pattern, you can wrap some complex logic to make it easier for the caller to invoke it. Just like providing a unified facade, the internal subsystems are encapsulated and unified into a high-level interface. A typical schematic diagram of the Facade pattern is as follows:
Figure 4-4 Facade mode
The purpose of the Facade pattern is not to introduce a new function, but to provide a higher level of abstraction based on the existing function, so that the caller can call it directly without worrying about the internal implementation. Taking the CacheDependency factory as an example, we need to provide the caller with an easy way to get the AggregateCacheDependency object, so we created the DependencyFacade class:
Public static class DependencyFacade {private static readonly string path = ConfigurationManager.AppSettings ["CacheDependencyAssembly"]; public static AggregateCacheDependency GetCategoryDependency () {if (! string.IsNullOrEmpty (path)) return DependencyAccess.CreateCategoryDependency (). GetDependency (); else return null;} public static AggregateCacheDependency GetProductDependency () {if (! string.IsNullOrEmpty (path)) return DependencyAccess.CreateProductDependency (). GetDependency (); else return null;} public static AggregateCacheDependency GetItemDependency () {if (! string.IsNullOrEmpty (path) return DependencyAccess.CreateItemDependency (). GetDependency (); else return null;}
The DependencyFacade class encapsulates the logic of getting an AggregateCacheDependency type object, so that the caller can call the relevant method to obtain the AggregateCacheDependency type object that creates the dependent dependency:
AggregateCacheDependency dependency = DependencyFacade.GetCategoryDependency ()
In addition to being simpler than directly calling the GetDependency () method of the DependencyAccess class, it also determines the CacheDependencyAssembly configuration section and returns a null object if its value is empty.
Under the App_Code folder of PetShop.Web, the GetCategoryName () and GetProductName () methods of the static class WebUtility call the DependencyFacade class. For example, the GetCategoryName () method:
Public static string GetCategoryName (string categoryId) {Category category = new Category (); if (! enableCaching) return category.GetCategory (categoryId) .Name; string cacheKey = string.Format (CATEGORY_NAME_KEY, categoryId); / / check whether the data item exists in the cache; string data = (string) HttpRuntime.Cache [cacheKey]; if (data = = null) {/ / obtain the durationvalue through web.config configuration; int cacheDuration = int.Parse (ConfigurationManager.AppSettings ["CategoryCacheDuration"]) / / if the data item does not exist in the cache, access the database to get it through the business logic layer; data = category.GetCategory (categoryId) .Name; / / create an AggregateCacheDependency object through the Facade class; AggregateCacheDependency cd = DependencyFacade.GetCategoryDependency (); / / store the data item and AggregateCacheDependency object in the cache; HttpRuntime.Cache.Add (cacheKey, data, cd, DateTime.Now.AddHours (cacheDuration), Cache.NoSlidingExpiration, CacheItemPriority.High, null);} return data;}
The GetCategoryName () method first checks whether the CategoryName data item already exists in the cache, and if so, obtains the data directly through the cache; otherwise, the CategoryName will be obtained by calling the data access layer through the business logic layer to access the database, and after obtaining the CategoryName, the newly acquired data will be added to the cache along with the AggregateCacheDependency object created by the DependencyFacade class.
The WebUtility static class is called by many pages in the presentation layer, such as Product pages:
Public partial class Products: System.Web.UI.Page {protected void Page_Load (object sender, EventArgs e) {Page.Title = WebUtility.GetCategoryName (Request.QueryString ["categoryId"]);}}
The logic for displaying the page title is placed in the Page_Load event method, so the method to get the CategoryName is executed each time the page is opened. Without the caching mechanism, when there is a lot of Category data, the display of the page will be very slow.
4.3.5 introduce Proxy mode
The business methods related to Product, Category and Item in the business logic layer BLL are implemented by calling data access layer (DAL) objects to access the database to obtain related data. In order to improve system performance, we need to add the logic of caching mechanism to these implementation methods. When we manipulate a business object that adds a caching mechanism, it should be consistent with the call to the BLL business object for the caller. In other words, we need to introduce a new object to control the original BLL business object, which is the proxy object in the Proxy schema.
Take the PetShop.BLL.Product business object as an example, PetShop establishes a proxy object ProductDataProxy for it, and introduces caching mechanisms in methods such as GetProductByCategory (), such as:
Public static class ProductDataProxy {private static readonly int productTimeout = int.Parse (ConfigurationManager.AppSettings ["ProductCacheDuration"]); private static readonly bool enableCaching = bool.Parse (ConfigurationManager.AppSettings ["EnableCaching"]); public static IListGetProductsByCategory (string category) {Product product = new Product (); if (! enableCaching) return product.GetProductsByCategory (category); string key = "product_by_category_" + category; IList data = (IList) HttpRuntime.Cache [key] / Check if the data exists in the data cache if (data = = null) {data = product.GetProductsByCategory (category); / / Create an AggregateCacheDependency object from the factory AggregateCacheDependency cd = DependencyFacade.GetProductDependency (); / / Store the output in the data cache, and Add the necessary AggregateCacheDependency object HttpRuntime.Cache.Add (key, data, cd, DateTime.Now.AddHours (productTimeout), Cache.NoSlidingExpiration, CacheItemPriority.High, null);} return data;}}
Compared with the GetProductsByCategory () method of the Product object in the business logic layer, the caching mechanism is added. When there are no related data items in the cache, the GetProductsByCategory () method of the business logic layer Product is directly called to obtain the data and store it in the cache together with the corresponding AggregateCacheDependency object.
The Proxy pattern is introduced to realize the encapsulation of the business object at the cache level and enhance the control of the business object. Because the methods exposed to the object are consistent, there is no substantial difference between the calling proxy object and the real object for the caller.
From the perspective of separation of responsibilities and hierarchical design, I prefer that these Proxy objects are defined in the business logic layer rather than divided into the presentation layer UI as in the PetShop design. In addition, if we need to consider the extensibility and replaceability of the program, we can also establish a unified interface or abstract class for real objects and proxy objects. However, it may be more reasonable to use static classes and static methods in terms of PetShop's presentation layer calls alone. We need to keep in mind that "overdesign" is the warning line of software design.
If you need to cache the UI layer and store the application data in the cache, you can call these proxy objects. Take the ProductsControl user control as an example, it is called as follows:
ProductsList.DataSource = ProductDataProxy.GetProductsByCategory (categoryKey)
The productsList object is of a custom CustomList type, which is a class derived from the System.Web.UI.WebControls.DataList control whose DataSource property accepts the IList collection object.
However, in the design of PetShop 4.0, for controls similar to the ProductsControl type, the caching mechanism used was page output caching. We can see this in the Source code on the ProductsControl.ascx page:
Unlike ASP.NET 1.x 's page output cache, ASP.NET 2.0 introduces a new CachePolicy property for ASP.NET user controls, which is of the type ControlCachePolicy class, which programmatically implements the output cache settings for ASP.NET user controls. We can set the dependencies related to the user control by setting the Dependency property of the ControlCachePolicy class, for example, in the ProductsControl user control, do the following:
Protected void Page_Load (object sender, EventArgs e) {this.CachePolicy.Dependency = DependencyFacade.GetProductDependency ();}
By using the page output cache and setting the output cache with ControlCachePolicy, the business data and the whole page can be put into the cache. This approach has a great improvement in performance compared to application caching. At the same time, it effectively avoids the disadvantage of "data expiration" through the introduction of SqlCacheDependency feature, so it is widely used in PetShop 4.0. In contrast, proxy objects previously established for Product, Category, and Item business objects are "idle", "surviving" only as a demonstration of a design method and in the source code of the entire system.
The above is all the content of the article "sample Analysis of ASP.NET caching in PetShop". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.