تقييمات الطلاب
( 5 من 5 )
١ تقييمات
فيديو شرح Different ways to cache application data in asp net Part 127 ضمن كورس ASP.net شرح قناة kudvenkat، الفديو رقم 127 مجانى معتمد اونلاين
Text version of the video
http://csharp-video-tutorials.blogspot.com/2013/02/different-ways-to-cache-application.html
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation1
Slides
http://csharp-video-tutorials.blogspot.com/2013/08/part-127-different-ways-to-cache.html
All ASP .NET Text Articles
http://csharp-video-tutorials.blogspot.com/p/free-aspnet-video-tutorial.html
All ASP .NET Slides
http://csharp-video-tutorials.blogspot.com/p/aspnet-slides.html
All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenkat/playlists?view1&sortdd
All Dot Net and SQL Server Tutorials in Arabic
https://www.youtube.com/c/KudvenkatArabic/playlists
In Part 126, of the asp.net video tutorial we discussed about, "Caching application data" using direct assignment as shown below. Please watch Part 126, from the asp.net video tutorial before proceeding.
Cache["Cache_Key"] Data_To_Cache
Link for asp.net tutorial
http://www.youtube.com/playlist?listPL6n9fhu94yhXQS_p1i-HLIftB9Y7Vnxlo
In this video we will discuss about
1. Different ways to cache application data
2. Removing an item from cache
3. Similarities and difference between cache and application state
Apart from caching data, using assignment, there are 2 other ways to cache application data
1. Using "Cache" object's Insert() method
2. Using "Cache" object's Add() method
Caching application data, using "Cache" object's Insert() method:
Cache object's, Insert() method has got 5 overloaded versions. Depending on application requirement, we can choose the overloaded version that best suits our needs. The simplest overloaded version, takes 2 parameters.
1. The Cache Key and
2. The data that we want to cache
In Part 126, we cached products dataset, using assignment as shown below
Cache["ProductsData"] ds;
The same thing can be achieved, using cache object's "Insert()" method, as shown below.
Cache.Insert("ProductsData", ds);
We will discuss about other overloaded versions of "Insert()" method in a later video session.
Caching application data, using "Cache" object's Add() method:
Adding application data, to the cache object, using "Add()" method is similar to "Insert()" method. As "Insert()" method has got several overloaded versions, some of the parameters are optional. Where as, "Add()" method does not have any overloads, and hence, all parameters must be specified.
Cache.Add("ProductsData", ds, null, System.Web.Caching.Cache.NoAbsoluteExpiration,System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, null);
We will discuss about "absolute expiration", "sliding expiration", and CacheItemPriority in a later video session.
Be cautious when dealing with cache keys: Assigning a value to a cache key, that is already being used will silently overwrite the existing value, without any warnings. For example
The value stored in "MyKey" is "Value1"
Cache["MyKey"] "Value 1";
The following line will silently overwrite "MyKey" value to "Value 2"
Cache["MyKey"] "Value 2";
To Remove an item from cache explicitly, use Remove() method. The following line would remove the cache item with key "MyKey"
Cache.Remove("MyKey");
Please Note: An item may be removed automatically, from cache, when any of the following conditions are true
The cached item has expired.
The cache is full.
There is a cache dependency, and the item, that the cache object is dependent on has changed.
In a way, Cache object is similar to Application state. The objects that we store in application state variables are available anywhere within a Web application. Objects stored in cache are also available anywhere within a Web application. But the difference is that, items stored in cache can expire, where as items in application state will never expire.