Apparently no-one else is mature enough to answer this guy's questions, so
let me give it a try.

> "The NH cache is for objects retrieved by NH"
> 
> I understand that.  What confuses me is that somebody wrote an API to take
> things out of that cache without writing an API to put things into it.
> 
> Why allow the ability to take something out of that cache?  Somebody had
> justification for writing such a function back in the day.

        The caching mechanism is in the o/r mapper, it's FOR the o/r mapper,
when it materializes entity class instances with the data from the db. So
objects end up in the cache because the o/r mapper decided to do so.

        It can be you need to remove an object from the cache, because you
removed it from the db using other means, e.g. a trigger, a separate process
on another machine, you name it. This way you can, in case of emergency,
remove it. I think that's the reason behind this method but we can only
guess, we didn't write the method. I agree that it's not a shiny example of
proper design, but NHibernate has plenty of that kind of hodgepodge stuff,
added during the years, as it's a framework which exists for a long time
(and inherited it from the Java version)

> So, isn't that same justification viable for a reason to be able to stuff
> something into that cache?  Even better yet a
> SessionFactory.Replace(object) would be perfect, because I just need to
take
> the new copy of Object A and overwrite the old Object A and have that new
> Object A be the master.

        that would mean you'd place yourself on the seat of the o/r mapper
which decides when to keep objects in the cache. That's not your job, leave
that to the o/r mapper. If you want to use a cache for your objects, use ...
a cache :) The l2 cache here is out of reach so use another one.

> "If you are getting it from other source, you can cache it yourself using
> the same underlying cache (syscache, memcached, etc)"
> 
> I'm not sure what you mean.  Are you saying there is a way to stuff an
> object into the L2 cache?  If so, how do I get at the SessionFactory's
> underlying memory structure that is used to implement that cache?  Or, are
> you saying that I should implement my own cache, separate from
> SessionFactory?  In that case, what good would it do, because
SessionFactory
> wouldn't be aware that I have a separate cache where it could find objects
> instead of selecting them.

        the underlying caching system used for l2 caching is the one you can
add the object to yourself, that's what was meant. 

                FB

> 
> Thanks for your help.
> Hugh
> 
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to