Try Playground
Show / Hide Table of Contents

Migrating from an AppFabric Application to NCache

To migrate from your AppFabric application to NCache, follow these steps:

Make the following changes in your application's source code:

  • Remove the Microsoft.ApplicationServer.Caching.Client NuGet package or references to the following AppFabric libraries from your application's source code:

    1. Microsoft.ApplicationServer.Caching.Client.dll
    2. Microsoft.ApplicationServer.Caching.Core.dll
  • Remove the following namespaces from your project:

    1. Microsoft.ApplicationServer.Caching
    2. Microsoft.ApplicationServer.Caching.Client
    3. Microsoft.ApplicationServer.Caching.Core
  • Download the NCache AppFabric Wrapper NuGet package in your application.

  • If you do not have NCache installed on your client machine, you can use the client.ncconf file added to your application project when you install the NCache AppFabric wrapper NuGet package to configure the cache client to access the NCache cluster. If you have NCache on your machine, you can find this file at %NCHOME%\config.

  • Add the Alachisoft.NCache.Data.Caching namespace in your project.

  • After you have installed the NuGet package and edited the namespaces, you need to configure the appSettings section of your App.config. Add the following keys and values to the appSettings:

    • <add key="Default" value="name-of-the-default-cache-here"/>
      Default is the ID of the default cache to use. This property is required if your application is calling the default cache.
    • <add key="Expirable" value="True"/>
      Expirable is a boolean value flag that determines whether the cached objects should have an expiry set on them. If you do not want to set an expiry on your cached items, then set this flag to False.
    • <add key="TTL" value="hh:mm:ss"/>
      TTL is the expiration time set on cached items.

An example of what your appSettings should look like is shown below.

<appSettings>
    <add key="Default" value="myDefaultCache"/>
    <add key="Expirable" value="True"/>
    <add key="TTL" value="05:30:00"/>
</appSettings>


Note
  • The TTL will not affect the cached items if the Expirable tag is False.
  • If the Expirable is set to True and no TTL is given, then the default expiration time of 10 min will be used on all cached items.
  • Next, you need to ensure the cache is created and running. If you use a local in-process cache as configured in the config.ncconf file, then that local server is already available to you, created, and running. You need to reference that cache as your cacheName. If you use an in-process local cache, ensure that the cache (with the ID provided in client.ncconf with the cache server configurations) is created and running. This cache must be mentioned as cacheName in your application. To create and start a cache, refer to our documentation on Configure Caches.
Note

Ensure the client.ncconf file has its cacheName set for you to configure a cache client that can access the cache.

These steps will allow you to connect your AppFabric application to the NCache cache and execute object-caching CRUD operations.

Additional Resources

NCache provides an AppFabric wrapper application and sample application on GitHub.

See Also

Configuration Differences Between AppFabric and NCache
.NET API Reference for NCache

Back to top Copyright © 2017 Alachisoft