DotNetKick.com is an open-source project. Please report any bugs and let us know your great suggestions. Currently running svn revision 620 (rss)

Kick Spy!, Kick Zeitgeist and Kick Widgets

36
kicks
published 2 months, 4 days ago, submitted by Vort3X 2 months, 5 days ago

objectreference.net — I develop for a large, high-availability website, with hundreds of thousands of daily users. As such, we need to cache a lot of data in our web-server memory (which is cheap) to save numerous hits to our main database cluster (which is very expensive). I would imagine the desire to improve performance by saving on database hits is common across many web applications – and caching frequently used data is often seen as one of the best ways to solve this problem.

Add a comment 6 comments | category: | Views: 42 | Get KickIt image code
tags: | tag it

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:

Comments:
Commenting here since the original site is broken and commenting doesn't work:
------------------
How do you deal with different parameters?
This seems to work when you retrieve always the exact same object, for example, the list with the top 10 news in a online newspaper
What if you need to retrieve, for example, a list of news by category? here there is now way to pass in a parameter.
posted by simonech simonech 2 months, 4 days ago
Also commenting here since the original site is broken.
--------------------------

What's the advantage of using a constructor like that vs a static property that basically contains the same code, this would mean you wouldn't need to create an instance of the SafeCache class to use it (however minor that is) I do think it would make the syntax of using it a little cleaner

Would also mean you could type this instead no?
DropDownList1.DataSource = SafeCache<Widgets>.Object.WidgetIds;
DropDownList1.DataBind();

That said the Activator.CreateInstance might be more of a performance hit anyway.

Have you also thought about abstracting your caching strategy out a little? basically meaning you rely on HttpContext.Current.Cache existing, if you were using this in a BusinessLogic class that you wanted to unit test I'm guessing you'd either have to go to extra effort to get it working (create a HttpContext it could use), change it to not use the cache if HttpContext.Current is null, or use some form of dependency injection to replace the httpcontext implementation with another custom one (say a static hash table)
posted by bzbetty 2 months, 4 days ago
Hi,

Regarding your suggestion of using a static property - I completely agree, and have updated the code sample accordingly.

Also, regarding the HttpContext dependency, I originally had a singleton implementation, which I removed from this post for the sake of brevity, however you've inspired me to put this back in, as some may find it useful.

simonech, Given the example you suggested, if using this, you'd be forced to cache the "whole newspaper" and use something like: SafeCache<Newspaper>.Object.Categories(2).

However, I think it might be possible to have a different version of this, which is parameterized generically, by having:

public SafeCache<Type, Parameter>
{
public Type GetObject(Parameter param)
{
//Get and cache including param.ToString() somehow in the cache-key
}
}

I'm sure there's probably a more flexible way of doing this.

Thanks for your ideas,
Dave
posted by Davbis93 2 months, 4 days ago
FYI: commenting seems to be working now
posted by simonech simonech 2 months, 4 days ago
that is a good article about caching.
mojtaba from <a href="http://www.vestasoftware.com">Vestasoft</a>
posted by mojtaba 1 month, 11 days ago
i didn't knew that this software changes the hyper links automatically
i meant http://www.vestasoftware.com
posted by mojtaba 1 month, 11 days ago



information Login or create an account to comment on this story
 

Sponsored Link: www.carlist.ie

Search:

Ads via The Lounge