PDA

View Full Version : Caching Help



trango1
04-29-2009, 09:02 PM
I need help getting the caching going. It simply is not going to my custom cache provider.

The cache provider implements the Spring.Caching.ICache interface.

the web config looks like:
<sectionGroup name="spring">
<section name="typeAliases" type="Spring.Context.Support.TypeAliasesSectionHandler, Spring.Core"/>
<section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHand ler, Spring.Core"/>
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
</sectionGroup>

...

<spring>
<parsers>
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/>
</parsers>
<context>
<resource uri="~/Config/Aspects.xml"/>

</context>
</spring>

...

<httpModules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
<add name="RewriteModule" type="mla.web.RewriteModule, MLAWeb3" />
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>

The Aspect.Xml looks like:

<objects xmlns="http://www.springframework.net">

<!-- Cache aspect -->
<object id="CacheAspect" type="Spring.Aspects.Cache.CacheAspect, Spring.Aop"/>
<object id="NCache" type="mla.caching.WebCache,mla.caching"/>
<object id="AspNetCache" type="Spring.Caching.AspNetCache, Spring.Web"/>


<!-- Apply aspects to DAOs -->
<object type="Spring.Aop.Framework.AutoProxy.ObjectNameAutoProxy Creator, Spring.Aop">
<property name="ObjectNames">
<list>
<value>*Article</value>
</list>
</property>
<property name="InterceptorNames">
<list>
<value>CacheAspect</value>
</list>
</property>
</object>


</objects>

the test method in(the class named 'Article') to be cached looks like:

[CacheResult("NCache", "'foo'", TimeToLive = "0:1:0")]
public List<IArticleModel> SearchArticles(object paramValueSource)
{

return dal.SearchArticles(paramValueSource);

}


but it never adds to cache or gets from cache....what am i missing. Thanks

Stingray
04-30-2009, 03:47 AM
Hi

We use NCache too.

We have the following in our config
<parsers>
<parser type="Spring.Aop.Config.AopNamespaceParser, Spring.Aop"/>
<parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/>
<parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data"/>
</parsers>

And the following

<object id="CachePointcut" type="Spring.Aspects.Cache.CacheAspect, Spring.Aop"/>

Doubt it makes any difference but we inherited from AbstractCache rather than ICache.

Cheers,