Currently using boltdb
for storing various entries in the bucket.
How can I use goroutines and channels in reading and updating in the db?
Generally, yes you can, provided you pay attention to the following points:
all accesses should be done in their own transactions. Transactions should not be shared between goroutines (whether they are read-only or read-write).
boltdb only tolerates one writer at a given point in time. If multiple concurrent transactions try to write at the same time, they will be serialized. The consistency of the database is guaranteed, but it has an impact on the performance, since write operations cannot be parallelized.
read-only transactions are executed concurrently (and potentially parallelized).
open only one transaction in a given goroutine at the same time to avoid deadlock situations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With