如何以编程方式加载NCache客户端配置的特定文件?

时间:2016-02-17 16:03:23

标签: ncache

我不希望将client.ncconf放在我的exe旁边,我希望能够以编程方式指定client.ncconf文件的路径。我怎么样?我正在使用NCache 4.4SP1开源。

我使用的方法主要是Web.Caching.NCache.InitializeCacheCache.Get

1 个答案:

答案 0 :(得分:1)

它从 %NCHOME% InstallDir/config中选择配置。 只需在AppSettings中添加以下内容

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

此外,可以使用CacheInitParams以编程方式指定所有客户端配置。你可以

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();
    }
}