Commit ddbdcbc3 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4cc99c49
...@@ -235,20 +235,20 @@ func (cache *LiveCache) Get(oid Oid) IPersistent { ...@@ -235,20 +235,20 @@ func (cache *LiveCache) Get(oid Oid) IPersistent {
return obj return obj
} }
// set sets objects corresponding to oid. // setNew sets objects corresponding to oid.
// XXX -> setNew? //
func (cache *LiveCache) set(oid Oid, obj IPersistent) { // The cache must not have previous entry for oid before setNew is called.
func (cache *LiveCache) setNew(oid Oid, obj IPersistent) {
var cp PCachePolicy var cp PCachePolicy
if cc := cache.control; cc != nil { if cc := cache.control; cc != nil {
cp = cache.control.PCacheClassify(obj) cp = cache.control.PCacheClassify(obj)
} }
// XXX remember cp in obj .pcachePolicy?
// XXX del .objtab[oid] ?
// XXX del .pinned[oid] ?
if cp & PCachePinObject != 0 { if cp & PCachePinObject != 0 {
cache.pinned[oid] = obj cache.pinned[oid] = obj
// XXX assert .objtab[oid] == nil ?
} else { } else {
cache.objtab[oid] = weak.NewRef(obj) cache.objtab[oid] = weak.NewRef(obj)
// XXX asseer .pinned[oid] == nil ?
} }
} }
...@@ -278,7 +278,7 @@ func (cache *LiveCache) SetControl(c LiveCacheControl) { ...@@ -278,7 +278,7 @@ func (cache *LiveCache) SetControl(c LiveCacheControl) {
cache.objtab = make(map[Oid]*weak.Ref) cache.objtab = make(map[Oid]*weak.Ref)
cache.pinned = make(map[Oid]IPersistent) cache.pinned = make(map[Oid]IPersistent)
c2.forEach(func(obj IPersistent) { c2.forEach(func(obj IPersistent) {
cache.set(obj.POid(), obj) cache.setNew(obj.POid(), obj)
}) })
} }
...@@ -292,7 +292,7 @@ func (conn *Connection) get(class string, oid Oid) (IPersistent, error) { ...@@ -292,7 +292,7 @@ func (conn *Connection) get(class string, oid Oid) (IPersistent, error) {
obj := conn.cache.Get(oid) obj := conn.cache.Get(oid)
if obj == nil { if obj == nil {
obj = newGhost(class, oid, conn) obj = newGhost(class, oid, conn)
conn.cache.set(oid, obj) conn.cache.setNew(oid, obj)
checkClass = false checkClass = false
} }
conn.cache.Unlock() conn.cache.Unlock()
......
...@@ -741,6 +741,7 @@ func TestLiveCache(t0 *testing.T) { ...@@ -741,6 +741,7 @@ func TestLiveCache(t0 *testing.T) {
103: PCachePinObject | PCacheDropState, 103: PCachePinObject | PCacheDropState,
// objDD - drop object and state // objDD - drop object and state
104: PCacheDropObject | PCacheDropState, 104: PCacheDropObject | PCacheDropState,
// XXX objDK ?
}} }}
t := tdb.Open(&ConnOptions{}) t := tdb.Open(&ConnOptions{})
......
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