     public func makeConnection(
         on worker: Worker
     ) -> Future<SQLiteConnection> {
-        let promise = Promise(SQLiteConnection.self)
-
+        // generate path
+        let path: String
         switch storage {
-        case .file(let path):
-            do {
-                let options = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_NOMUTEX
-                var raw: SQLiteConnection.Raw?
-                guard sqlite3_open_v2(path, &raw, options, nil) == SQLITE_OK else {
-                    throw SQLiteError(problem: .error, reason: "Could not open database.")
+        case .file(let p): path = p
+        case .memory:
+            if let cached = cachedFilePath {
+                path = cached
+            } else {
+                let new = "/tmp/\(UUID()).sqlite"
+                if FileManager.default.fileExists(atPath: new) {
+                    fatalError("SQLite database already exists at: \(new)")
                 }
-
-                guard let r = raw else {
-                    throw SQLiteError(problem: .error, reason: "Unexpected nil database.")
-                }
-
-                let conn = SQLiteConnection(raw: r, database: self, on: worker)
-                promise.complete(conn)
-            } catch {
-                promise.fail(error)
-            }
-        case .memory:
-            /// must be FULL MUTEX to re-use between workers
-            if let cached = cachedConnection {
-                promise.complete(cached)
-            } else {
-                do {
-                    let options = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_FULLMUTEX
-                    var raw: SQLiteConnection.Raw?
-                    guard sqlite3_open_v2(":memory:", &raw, options, nil) == SQLITE_OK else {
-                        throw SQLiteError(problem: .error, reason: "Could not open database.")
-                    }
-
-                    guard let r = raw else {
-                        throw SQLiteError(problem: .error, reason: "Unexpected nil database.")
-                    }
-
-                    let conn = SQLiteConnection(raw: r, database: self, on: worker)
-                    cachedConnection = conn
-                    promise.complete(conn)
-                } catch {
-                    promise.fail(error)
-                }
+                cachedFilePath = new
+                path = new
             }
         }
-        
+
+        // make connection
+        let promise = Promise(SQLiteConnection.self)
+        do {
+            let options = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_NOMUTEX
+            var raw: SQLiteConnection.Raw?
+            guard sqlite3_open_v2(path, &raw, options, nil) == SQLITE_OK else {
+                throw SQLiteError(problem: .error, reason: "Could not open database.")
+            }
+
+            guard let r = raw else {
+                throw SQLiteError(problem: .error, reason: "Unexpected nil database.")
+            }
+
+            let conn = SQLiteConnection(raw: r, database: self, on: worker)
+            promise.complete(conn)
+        } catch {
+            promise.fail(error)
+        }
         return promise.future
     }
 }

    public var logger: SQLiteLogger?

    /// Used for in-memory DB.
    private var cachedConnection: SQLiteConnection?

    /// Create a new SQLite database.
    public init(storage: SQLiteStorage) {

import Async
import CSQLite
import Dispatch
import Foundation

/// SQlite database. Used to make connections.
public final class SQLiteDatabase {
