Business Layer cache in the business object
ASP.NET Cache mechanism of the page, the user controls and custom cache, the paper provides a cache in the business of business object method.
The use of ASP.NET Cache mechanism can improve the overall performance of the Web server. ASP.net pages provided in the Presentation Layer controls and user-level cache, and can be realized only through a statement caching function is easy to use.
But Presentation Layer cache the following problems:
— For the relatively static content (equivalent to the Java Session Bean), such as Product List;
— Based on the content of different customers (equivalent to the Java Entity Bean), to QueryString to different content cache;
— Especially the business information needs of the same customer in different ways has the time (such as full / part statements / charts, etc.) need to spend a lot of resources;
— When relevant content updates, it is difficult to update (or void) cache content.
In addition, expenses from the perspective of system resources, network access and disk access is far greater than the overhead pages Rendering, thus reducing database visit is the focus of system optimization.
In short, chicken striker used in the project in the Business Layer cache method. Concrete realization of the following:
— Definitions CachedObject category, packaging HttpContext.Current.Cache target
— Cache mechanism for weeding out the first visit by an increase every n seconds validity period is divided into short, medium and long and permanent 4th speed
— In every business category to achieve an increase in private member variables _ cache CachedObject
— Access to customer data business template method is as follows:
Public Something GetSomething ()
(
GetCacheKey string cacheKey = ( "GetSomething");
If (null == _cache [cacheKey])
_cache GetFromDatabase [cacheKey] = () / / default valid for midrange
Return _cache [cacheKey] as Something;
)
— Set the operational methods of data templates are as follows:
Public void SetSomething (Something value)
(
SetToDatabase (value);
GetCacheKey string cacheKey = ( "GetSomething");
_cache.remove (CacheKey);
)
— GetCacheKey () for the production of certain types of operation of a client cache key values, such as:
String GetCacheKey (string unique)
(
/ / _ Presumed to customers logo customerID
Return String.Concate (unique, _customerID.ToString ());
)
Tags: object








0 Comments to “Business Layer cache in the business object”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.