How to programmatically load a specific file for NCache client configuration?

309 views Asked by At

Not wanting to leave a client.ncconf lying aside my exe, I wish to be able to specify the path to the client.ncconf file programatically. How may I? I am using NCache 4.4SP1 Open Source.

The methods I am using are mainly Web.Caching.NCache.InitializeCache and Cache.Get.

1

There are 1 answers

5
Basit Anwer On

It picks the config from %NCHOME% InstallDir/config. Just add the following in your AppSettings

<add key="InstallDir" value="C:\temp"/>

Also, all the client configurations can be specified programmatically using the CacheInitParams. You can

namespace Alachisoft.NCache.Web.Caching
{
    public class CacheInitParams : ICloneable
    {
        public CacheInitParams();

        public string BindIP { get; set; }
        public ClientCacheSyncMode ClientCacheSyncMode { get; set; }
        public int ClientRequestTimeOut { get; set; }
        public int CommandRetries { get; set; }
        public int CommandRetryInterval { get; set; }
        public int ConnectionRetries { get; set; }
        public int ConnectionTimeout { get; set; }
        public string DefaultReadThruProvider { get; set; }
        public string DefaultWriteThruProvider { get; set; }
        public bool LoadBalance { get; set; }
        public CacheMode Mode { get; set; }
        [Obsolete("This property is deprecated. Please use the 'ServerList' property instead.", false)]
        public int Port { get; set; }
        public SecurityParams PrimaryUserCredentials { get; set; }
        public int RetryConnectionDelay { get; set; }
        public int RetryInterval { get; set; }
        public SecurityParams SecondaryUserCredentials { get; set; }
        [Obsolete("This property is deprecated. Please use the 'ServerList' property instead.", false)]
        public string Server { get; set; }
        public CacheServerInfo[] ServerList { get; set; }

        public object Clone();
    }
}