allegro / allegro/bigcache

FeatureRequest: provide PinnedSlice or something to avoid memmove

Aperta
#230 7 commenti 1 reazione 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Go
Stelle
8.2k
Fork
614
Merge medio
5g 12h
PR unite (30g)
1

Descrizione

For now, every time we get an entry from bigcache when cache hit, bigcache will allocate a new
byte slice and copy cache content into it internally. I propose to provide a way to let users to manage the lifetime of the entry they got, to avoid internal memory copy.
```
type PinnedSlice struct {...}
func (this PinnedSlice) Copy() PinnedSlice {...}
func (this PinnedSlice) Release() {...}
func (c *BigCache) GetPinnedSlice(key string) (PinnedSlice, error)
```
Internally, we can add a reference count in the header of wrapped entry, just like timestamps. Once we want to evict an entry, we need to check whether its reference count is zero, if not, we should jump across it and check next entry.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.