Commit 1e6aeeee authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb: LiveCache: Reclassify all objects on cache control change

If cache control changes, all objects needs to go through new cache
control as what was e.g. pinned before could be in other class
from the point of view of new cache control.

Tests pending...
parent 4357db3f
......@@ -268,6 +268,14 @@ func (cache *LiveCache) forEach(f func(IPersistent)) {
// It is not safe to call SetControl simultaneously to other cache operations.
func (cache *LiveCache) SetControl(c LiveCacheControl) {
cache.control = c
// reclassify all objects
c2 := *cache
cache.objtab = make(map[Oid]*weak.Ref)
cache.pinned = make(map[Oid]IPersistent)
c2.forEach(func(obj IPersistent) {
cache.setNew(obj.POid(), obj)
})
}
// get is like Get, but used when we already know object class.
......
......@@ -816,6 +816,8 @@ func TestLiveCache(t0 *testing.T) {
assert.Equal(obj._v_cookie, "")
assert.Equal(objDD._v_cookie, "")
// TODO reclassify tests
}
// TODO Map & List tests.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment