forked from TrueCloudLab/frostfs-node
[#1523] writecache: Simplify logic
1. Remove in-memory cache. It doesn't persist objects and if we want more speed, `NoSync` option can be used for the bolt DB. 2. Put to the metabase in a synchronous fashion. This considerably simplifies overall logic and plays nicely with the metabase bolt DB batch settings. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
4176b2a1bc
commit
ddaed283e9
9 changed files with 140 additions and 328 deletions
|
@ -14,20 +14,6 @@ import (
|
|||
func (c *cache) Get(addr oid.Address) (*objectSDK.Object, error) {
|
||||
saddr := addr.EncodeToString()
|
||||
|
||||
c.mtx.RLock()
|
||||
for i := range c.mem {
|
||||
if saddr == c.mem[i].addr {
|
||||
data := c.mem[i].data
|
||||
c.mtx.RUnlock()
|
||||
// We unmarshal object instead of using cached value to avoid possibility
|
||||
// of unintentional object corruption by caller.
|
||||
// It is safe to unmarshal without mutex, as storage under `c.mem[i].data` slices is not reused.
|
||||
obj := objectSDK.New()
|
||||
return obj, obj.Unmarshal(data)
|
||||
}
|
||||
}
|
||||
c.mtx.RUnlock()
|
||||
|
||||
value, err := Get(c.db, []byte(saddr))
|
||||
if err == nil {
|
||||
obj := objectSDK.New()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue