Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 4839dc01da
Fetching contributors…

Cannot retrieve contributors at this time

17 lines (12 sloc) 0.749 kB
package com.twitter.querulous.database
import scala.collection.mutable
class MemoizingDatabaseFactory(databaseFactory: DatabaseFactory) extends DatabaseFactory {
private val databases = new mutable.HashMap[String, Database] with mutable.SynchronizedMap[String, Database]
def apply(dbhosts: List[String], dbname: String, username: String, password: String, urlOptions: Map[String, String]) = synchronized {
databases.getOrElseUpdate(
dbhosts.first + "/" + dbname,
databaseFactory(dbhosts, dbname, username, password, urlOptions))
}
// cannot memoize a connection without specifying a database
override def apply(dbhosts: List[String], username: String, password: String) = databaseFactory(dbhosts, username, password)
}
Jump to Line
Something went wrong with that request. Please try again.