[#726] writecache: Fix small object flush for Badger
All checks were successful
DCO action / DCO (pull_request) Successful in 2m25s
Vulncheck / Vulncheck (pull_request) Successful in 2m41s
Build / Build Components (1.21) (pull_request) Successful in 3m2s
Build / Build Components (1.20) (pull_request) Successful in 3m17s
Tests and linters / Staticcheck (pull_request) Successful in 4m26s
Tests and linters / Tests (1.20) (pull_request) Successful in 6m9s
Tests and linters / Tests (1.21) (pull_request) Successful in 18m15s
Tests and linters / Lint (pull_request) Successful in 20m21s
Tests and linters / Tests with -race (pull_request) Successful in 18m2s

Do not marshal object twice.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-10-06 11:31:40 +03:00
parent 997ac7cd8d
commit d07afd803c
2 changed files with 12 additions and 9 deletions

View file

@ -21,7 +21,7 @@ type cache struct {
modeMtx sync.RWMutex
// flushCh is a channel with objects to flush.
flushCh chan *objectSDK.Object
flushCh chan objectInfo
// scheduled4Flush contains objects scheduled for flush via flushCh
// helps to avoid multiple flushing of one object
scheduled4Flush map[oid.Address]struct{}
@ -52,7 +52,7 @@ const (
// New creates new writecache instance.
func New(opts ...Option) writecache.Cache {
c := &cache{
flushCh: make(chan *objectSDK.Object),
flushCh: make(chan objectInfo),
mode: mode.ReadWrite,
scheduled4Flush: map[oid.Address]struct{}{},