TAILIEUCHUNG - Caching Data

[ Team LiB ] Recipe Caching Data Problem Given a Web Forms application that is performing poorly because it is repeatedly reading data that doesn't change very often, you need to cache the data to eliminate unnecessary queries and improve the performance. Solution Use the Cache class. | Team LiB Recipe Caching Data Problem Given a Web Forms application that is performing poorly because it is repeatedly reading data that doesn t change very often you need to cache the data to eliminate unnecessary queries and improve the performance. Solution Use the Cache class. The Web Forms page defines the data grid used to display the contents of a DataSet a button to clear the cache and a label that displays whether the data was retrieved from the cache or from the database. The code for the Web Forms page is shown in Example 9-3. Example 9-3. File form id ADOCookbookCS0903 method post runat server asp HyperLink id HyperLink1 style Z-INDEX 101 LEFT 16px POSITION absolute TOP 24px runat server NavigateUrl Main Menu asp HyperLink asp DataGrid id customersDataGrid style Z-INDEX 102 LEFT 16px POSITION absolute TOP 128px runat server AllowPaging True HeaderStyle Font-Bold True HeaderStyle asp DataGrid asp Label id cacheStatusLabel style Z-INDEX 103 LEFT 16px POSITION absolute TOP 96px runat server ForeColor Green asp Label asp Button id clearCacheButton style Z-INDEX 104 LEFT 16px POSITION absolute TOP 56px runat server Text Clear Cache asp Button form The code-behind contains three event handlers and two methods Checks the cache for an object with the key CustomerDataSet. If an entry is not found the DataSet is loaded by calling the LoadDataSet method. If an entry is found the cached object is retrieved and cast to a DataSet. In either case the source of the data is displayed to the user. If the page is being loaded for the first time the CurrentPageIndex of the data grid on the page is set to 0 the first page and the BindDataGrid method is called to bind the default view of the Customers table to the data grid on the form. LoadDataSet This method loads a DataSet with the Customers table from the Northwind database. The DataSet is added to the cache with the key CustomerDataSet and an expiration time of .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.