views:

42

answers:

1

i am using the Toxi solution on this site for tagging bookmarks:

http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html

In controllers, i have a LinkController class

class LinkController

ActionResult AddNewLink(FormCollection collection_)
ActionResult Index()

In Models, i have a LinkRepository:

class LinkRepository

void AddLink(string url, string description, string[] tags)
WebLink[] GetLinks(string[] tags)
WebLink[] GetLinks()

I also have a Tag Repository class:

class TagRepository

string[] GetTags()

My question, is when i want to add new links, i need to update the Tag table and i want that to be optimized. To do that i need to cache the tags somewhere do i dont waste time in the db trying to addd tags that already exists. Do i cache these tags by:

A. Having the LIinkRepository have a reference to the Tag Repository and caching on instantiating
B. Having the LinkController cache it (this feels weird as it would then convert tags to a smaller set of tags that didnt' exist)
C. Other options?

+2  A: 

Start by working without caching, until you know you edit the data in correct ways etc. Depending on the usage of your application, caching might not even be necessary...

If it turns out your application does not perform well enough, start by caching in the Repository. It's the DB calls that will be the biggest performance killer, and you shouldn't go further than the repository to cacheliminate (yes, I just invented that word) those. If you still experience performance problems, cache at the controller as well.

Tomas Lycken
Agreed, preamture optimization is the root of all evil ;)
Daniel Elliott