aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2019-05-29 17:43:13 +0900
committerGitHub <noreply@github.com>2019-05-29 17:43:13 +0900
commit070b17a2fdf5109d2dd54acb6bbfb507872115cf (patch)
treeda1a5195018709808554da2b2b1be09134cddbf2
parentCreate FUNDING.yml (diff)
parentmore code formatting (diff)
downloadgolite-070b17a2fdf5109d2dd54acb6bbfb507872115cf.tar.gz
golite-070b17a2fdf5109d2dd54acb6bbfb507872115cf.tar.xz
Merge pull request #680 from rittneje/improve-faq-in-memory-shared-cache
improve FAQ re: in-memory databases
-rw-r--r--README.md12
1 files changed, 8 insertions, 4 deletions
diff --git a/README.md b/README.md
index 3b2f695..bf65a00 100644
--- a/README.md
+++ b/README.md
@@ -456,15 +456,19 @@ For an example see [shaxbee/go-spatialite](https://github.com/shaxbee/go-spatial
Why is it racy if I use a `sql.Open("sqlite3", ":memory:")` database?
- Each connection to :memory: opens a brand new in-memory sql database, so if
+ Each connection to `":memory:"` opens a brand new in-memory sql database, so if
the stdlib's sql engine happens to open another connection and you've only
- specified ":memory:", that connection will see a brand new database. A
- workaround is to use "file::memory:?mode=memory&cache=shared". Every
- connection to this string will point to the same in-memory database.
+ specified `":memory:"`, that connection will see a brand new database. A
+ workaround is to use `"file::memory:?cache=shared"` (or `"file:foobar?mode=memory&cache=shared"`). Every
+ connection to this string will point to the same in-memory database.
+
+ Note that if the last database connection in the pool closes, the in-memory database is deleted. Make sure the [max idle connection limit](https://golang.org/pkg/database/sql/#DB.SetMaxIdleConns) is > 0, and the [connection lifetime](https://golang.org/pkg/database/sql/#DB.SetConnMaxLifetime) is infinite.
For more information see
* [#204](https://github.com/mattn/go-sqlite3/issues/204)
* [#511](https://github.com/mattn/go-sqlite3/issues/511)
+ * https://www.sqlite.org/sharedcache.html#shared_cache_and_in_memory_databases
+ * https://www.sqlite.org/inmemorydb.html#sharedmemdb
- Reading from database with large amount of goroutines fails on OSX.