Permalink
Browse files

Merge pull request #79 from tjake/keyspace-fix

Don't call setKeyspace if connection already active in the same keyspace
  • Loading branch information...
nberardi committed Oct 12, 2012
2 parents 40c6d5d + 66a9162 commit ca6f2d420d0f9d02f76e368b7a35f6243ec304ef
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/Connections/Connection.cs
@@ -14,6 +14,7 @@ public class Connection : IConnection, IDisposable
{
private TTransport _transport;
private Cassandra.Client _client;
+ private string _activeKeyspace;
private readonly object _lock = new object();
/// <summary>
@@ -166,7 +167,11 @@ public void SetKeyspace(string keyspace)
if (!IsOpen)
throw new CassandraConnectionException("A connection to Cassandra has not been opened.");
- Client.set_keyspace(keyspace);
+ if (_activeKeyspace == null || !_activeKeyspace.Equals(keyspace))
+ {
+ Client.set_keyspace(keyspace);
+ _activeKeyspace = keyspace;
+ }
}
/// <summary>

0 comments on commit ca6f2d4

Please sign in to comment.