Apply NCache to existing project (with CacheDependency)

158 Views Asked by At

Help/Answers in C# or VB.net are fine

I have a large project that currently uses system.web.Caching.CacheDependency, example

Dim myCacheDep as new CacheDependency(FilePath)
HttpRuntime.Cache.Insert(key, value, myCacheDep)

Now, i am trying to setup NCache and ideally change minimal lines (but the above occurs in hundreds of places.

Because i need to pass in the NCache.Runtime.Dependencies.CacheDependency, Doing the following will not work:

Dim myCacheDep as new CacheDependency(FilePath)
Dim nCache As Alachisoft.NCache.Web.Caching.Cache = NCache.InitializeCache("testID")
nCache.Insert(key, value, myCacheDep , absoluteExpiration, slidingExpiration, CacheItemPriority.Default)

Because we are trying to pass a system....CacheDependency instead of the NCache....CacheDependency

Any suggestions to achieve this, and the cleanest way?

Thank you

1

There are 1 best solutions below

0
On

Microsoft used to provide caching support through its Enterprise library caching application block (CAB) and NCache had a provider to use with it that didn't require any application code changes. Since .NET Framework 4.0 release, however, Microsoft has discontinued the Caching Application Block functionality. Microsoft from then on has been giving built-in caching capabilities, ceasing support for provider models that allowed for 3rd party integrations such as NCache to plug into it. Hence, NCache doesn't have this feature anymore.

Moreover, it is best if you start replacing System.Web.Caching calls with NCache Alachisoft.NCache.Web.Caching calls yourself and take advantage of NCache APIs that are much more feature-rich. You can visit the following link to get more information on the different NCache options and their usage:

http://www.alachisoft.com/resources/docs/ncache/prog-guide/

You can also check out our samples provided in %NCHOME%\NCache\samples\dotnet folder (%NCHOME% is the NCache installation directory on your machine e.g. C:\Program Files) and see how NCache APIs are actually used in applications. You can start with the sample BasicOperations as that includes all the basic NCache APIs.