> So how are you going to get that new user type when an admin changes it on
> the fly?
It will be reflected only after the user logs out and back in.
> menu? I guess it doesn't matter. The thing is, using the VaryByParam
> property of the cache object, when it sees a different user type, its going
> to pull the cached menu associated with that user type parameter.
Hmmm... well, it gets slightly more complicated. You see, the admin
can also change the rights that a user has ==> the menu should now
show different options. So even when the type remains the same, the
menu can be different. Once changed, though, the menu will be the same
for all users of that type.
> As far as clearing the cache at the end of a session, well, you can always
> do a Cache.Remove("MyMenuItem") in the Session_End method of the
> global.asax, but you are defeating your purpose of caching the object in
> Cache by doing that.
I thought about that, but wouldn't this require me to manually put it
in the cache? i.e., with Cache.Insert()? Suppose I'm relying on the
@OutputCache directive... how would I know the key that is used to
cache the control?
Now... let's say I do decide to cache the control manually with
Cache.Insert(). How do I place this control on my form? I'm thinking
that I'll use a place holder and then do
myMenu = Session("myControl") as MyMenuControl;
myPlaceHolder.Controls.Add(myMenu);
> is destroyed, so will be that menu stored for their session. The drawback
> here is that if you have 10 users logged in under the same user type, they
> all won't be using the same cached menu object, but each will have his own
> copy of the same menu.
You're right... I will have to store a cache for each session. Is
there a more elegant solution to the situation? Perhaps I can use an
Application level cache that is updated everytime a new session is
created. This way, all users share one copy of the menu, and it gets
created and updated only when a new user logs on. What do you think?
Thanks.