Browse Source

Use constant for default max prepared statements

Oliver Beattie 10 years ago
parent
commit
779e083198
2 changed files with 4 additions and 2 deletions
  1. 3 1
      cluster.go
  2. 1 1
      conn.go

+ 3 - 1
cluster.go

@@ -12,6 +12,8 @@ import (
 	"github.com/golang/groupcache/lru"
 )
 
+const defaultMaxPreparedStmts = 1000
+
 //Package global reference to Prepared Statements LRU
 var stmtsLRU preparedLRU
 
@@ -86,7 +88,7 @@ func NewCluster(hosts ...string) *ClusterConfig {
 		Consistency:      Quorum,
 		ConnPoolType:     NewSimplePool,
 		DiscoverHosts:    false,
-		MaxPreparedStmts: 1000,
+		MaxPreparedStmts: defaultMaxPreparedStmts,
 	}
 	return cfg
 }

+ 1 - 1
conn.go

@@ -366,7 +366,7 @@ func (c *Conn) ping() error {
 func (c *Conn) prepareStatement(stmt string, trace Tracer) (*QueryInfo, error) {
 	stmtsLRU.Lock()
 	if stmtsLRU.lru == nil {
-		initStmtsLRU(1000)
+		initStmtsLRU(defaultMaxPreparedStmts)
 	}
 
 	stmtCacheKey := c.addr + c.currentKeyspace + stmt