예제 #1
0
 public Redis(int maxWritePoolSize, int maxReadPoolSize, string[] readWriteHosts, string[] readOnlyHosts, long initalDb, TimeSpan defaultExpirationTime)
 {
     try
     {
         try
         {
             var config = new RedisClientManagerConfig
             {
                 MaxWritePoolSize = maxWritePoolSize, //“写”链接池链接数
                 MaxReadPoolSize  = maxReadPoolSize,  //“读”链接池链接数
                 AutoStart        = true,
             };
             PooledRedisClientManager.Add(initalDb, new PooledRedisClientManager(readWriteHosts, readOnlyHosts, config, initalDb, null, null));
         }
         catch (Exception e)
         {
             //LFFK.LogManager.Error(CacheConstants.Error_Init, e);
         }
         DefaultExpirationTime = defaultExpirationTime;
         InitalDb         = initalDb;
         ReadWriteHost    = readWriteHosts[0];
         MaxWritePoolSize = maxWritePoolSize;
         MaxReadPoolSize  = maxReadPoolSize;
         ReadWriteHosts   = readWriteHosts;
         ReadOnlyHosts    = readWriteHosts;
         PersistentClient.Add(initalDb, new RedisClient(ReadWriteHost.Split(':')[0], Convert.ToInt32(ReadWriteHost.Split(':')[1]), db: initalDb));
     }
     catch (Exception ex)
     {
         throw new Exception(Constants.Error_Data_InitConfigFailed, ex);
     }
 }