@Diego: thanks for the reply. You're probably right. What I was thinking is that NH already provides agnostic caching interfaces, so I thought I'd try and leverage them. Writing my own wrapper service was a fallback approach for me, but you make it sound more attractive than I originally thought.
Best, Kent On Mar 3, 11:20 am, Diego Mijelshon <[email protected]> wrote: > While you _could_ do something like the following... > > var cache = > ((ISessionFactoryImplementor)sessionFactory).Settings.CacheProvider.BuildCache(regionName, > null); > > It makes no sense from my perspective. Just because NH uses a cache doesn't > mean your code should use NH to get to that cache. > Instead, inject the NH cache provider in code and use the same code to > inject the corresponding cache into the classes that use it as a general > cache. You'll should build a generic IGeneralPurposeCache interface that > doesn't depend on NH. > > Diego > > On Wed, Mar 3, 2010 at 06:34, Kent Boogaart <[email protected]> wrote: > > Does anyone have any thoughts on this? Is it not possible to do this? > > > Thanks, > > Kent > > > On Mar 2, 12:33 pm, Kent Boogaart <[email protected]> wrote: > > > If I have configured NH to use a second level cache, is it possible to > > > get a hold of a reference to the ICacheProvider or ICache in question? > > > > I would like to use the same cache for non-DB data, preferably without > > > taking a dependency on any one particular caching implementation. > > > Thus, it would be nice if I could do something like this: > > > > public void SomeMethod() > > > { > > > ICache cache = sessionFactory.GetCache(); > > > var cachedValue = cache.GetValue("someKey"); > > > > if (cachedValue == null) > > > { > > > // calculate value and cache it > > > } > > > > // do something with calculated value > > > > } > > > > Question is, how would I write that first line of code that gets the > > > ICache implementation? > > > > Thanks > > > -- > > 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]<nhusers%[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.
