Yes, if you are only ever going to have a single instance of Badger active at any time, making BypassLockGuard true is usually safe. This flag permits you to opt out of some of the locking within, potentially enhancing performance when you know there will be no concurrent access. But even when BypassLockGuard is true, Badger remains safe to use with multiple goroutines, provided you are only accessing the database in one instance at a time. Badger’s underlying structure is still concurrent-safe within one instance, so using it with multiple goroutines (provided each operation is contained to one goroutine at a time) should be okay. Just remember that BypassLockGuard doesn’t eliminate all concurrency protection, it simply disables some internal locks that are not required in your particular scenario.
1 Like