Example #1
0
 public IRedisClientConnection TryGetConnection()
 {
     if (connection != null)
     {
         //case 1: already available connection
         return(connection);
     }
     else
     {
         //case 2: we are allowed to create first connection
         lock (lockObject)
         {
             // make sure it is not created by other request in between
             if (connection == null)
             {
                 connection = factory.Invoke();
                 connection.Open();
             }
         }
         return(connection);
     }
 }
 public IRedisClientConnection TryGetConnection()
 {
     if (connection != null)
     {
         //case 1: already available connection
         return connection;
     }
     else
     {
         //case 2: we are allowed to create first connection
         lock (lockObject)
         {
             // make suer it is not created by other request in between
             if (connection == null)
             {
                 connection = factory.Invoke();
                 connection.Open();
             }
         }
         return connection;
     }
 }