You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.
Only one read-write transaction is allowed at a time.
From documentation I understand that concurrent writes are not allowed. I'm not sure if this is correct thus this question to clarify: is boltdb designed only for one single writer (globally)? Am I suppose to maintain a lock on any write?
Use case:
I want to store access logs of http requests. Does this mean that I need to use a global channel to serialise the access bolt writes ?
e.g.
var globalChan = make(chan string, 10)
func init() {
const bucketName = "widgets"
tx, err := db.Begin(true)
if err != nil {
panic(err)
}
_, err = tx.CreateBucketIfNotExists([]byte(bucketName))
if err != nil {
return err
}
go func() {
for URL := range globalCHan {
tx, err := db.Begin(true)
if err != nil {
panic(err)
}
bk := tx.Bucket([]byte(bucketName))
// Set the value "bar" for the key "foo".
if err := b.Put([]byte(time.Now().String()), []byte("bar")); err != nil {
return err
}
}
}()
}
func HandleFunc(w http.ResponseWriter, r *http.Request) {
globalChan <- r.URL.String()
}
The text was updated successfully, but these errors were encountered:
From documentation I understand that concurrent writes are not allowed. I'm not sure if this is correct thus this question to clarify: is boltdb designed only for one single writer (globally)? Am I suppose to maintain a lock on any write?
Use case:
I want to store access logs of http requests. Does this mean that I need to use a global channel to serialise the access bolt writes ?
The text was updated successfully, but these errors were encountered: