[#1060] writecache: compress big object if needed

Small objects use `blobstor.Put`, so no changes are required.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-01-11 14:33:04 +03:00 committed by Alex Vanin
parent 0d969d7a06
commit 486d5c2e86
5 changed files with 36 additions and 12 deletions

View file

@ -31,10 +31,14 @@ type Cache interface {
type cache struct {
options
// mtx protects mem field, statistics and counters.
// mtx protects mem field, statistics, counters and compressFlags.
mtx sync.RWMutex
mem []objectInfo
// compressFlags maps address of a big object to boolean value indicating
// whether object should be compressed.
compressFlags map[string]struct{}
// curMemSize is the current size of all objects cached in memory.
curMemSize uint64
@ -80,6 +84,7 @@ func New(opts ...Option) Cache {
closeCh: make(chan struct{}),
evictCh: make(chan []byte),
compressFlags: make(map[string]struct{}),
options: options{
log: zap.NewNop(),
maxMemSize: maxInMemorySizeBytes,