Commit 5d69ba25 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 7a036b15
...@@ -61,10 +61,9 @@ type Connection struct { ...@@ -61,10 +61,9 @@ type Connection struct {
// //
// but does not hold strong reference to cached objects. // but does not hold strong reference to cached objects.
// //
// LiveCache is safe to access for multiple-readers / single-writer. // LiveCache is not safe to use from multiple goroutines simultaneously.
// To do so the caller must explicitly serialize access with e.g. .Lock() .
// //
// XXX try to hide locking from user? // Use .Lock() / .Unlock() to serialize access.
type LiveCache struct { type LiveCache struct {
// rationale for using weakref: // rationale for using weakref:
// //
...@@ -196,18 +195,13 @@ func (cache *LiveCache) SetControl(c LiveCacheControl) { ...@@ -196,18 +195,13 @@ func (cache *LiveCache) SetControl(c LiveCacheControl) {
// Use-case: in ZODB references are (pyclass, oid), so new ghost is created // Use-case: in ZODB references are (pyclass, oid), so new ghost is created
// without further loading anything. // without further loading anything.
func (conn *Connection) get(class string, oid Oid) (IPersistent, error) { func (conn *Connection) get(class string, oid Oid) (IPersistent, error) {
checkClass := true
conn.cache.Lock() // XXX -> rlock? conn.cache.Lock() // XXX -> rlock?
obj := conn.cache.Get(oid) obj := conn.cache.Get(oid)
checkClass := false
if obj == nil { if obj == nil {
obj = newGhost(class, oid, conn) obj = newGhost(class, oid, conn)
//if obj == nil {
// conn.cache.Unlock()
// return nil, fmt.Errorf("get %s: class %q not supported", Xid{conn.at, oid}, class)
//}
conn.cache.objtab[oid] = weak.NewRef(obj) conn.cache.objtab[oid] = weak.NewRef(obj)
} else { checkClass = false
checkClass = true
} }
conn.cache.Unlock() conn.cache.Unlock()
......
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