Commit aa23bcda authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4672ebb0
......@@ -118,7 +118,7 @@ type LiveCache struct {
objtab map[Oid]*weak.Ref // oid -> weak.Ref(IPersistent)
// hooks for application to influence live caching decisions.
cacheControl LiveCacheControl
control LiveCacheControl
}
// LiveCacheControl is the interface that allows applications to influence
......@@ -182,6 +182,16 @@ func (cache *LiveCache) Get(oid Oid) IPersistent {
return obj
}
// SetControl installs c to handle cache decisions.
//
// Any previously installed cache control is uninstalled.
// Passing nil sets the cache to have no control installed at all.
//
// It is not safe to call SetControl simultaneously to other cache operations.
func (cache *LiveCache) SetControl(c LiveCacheControl) {
cache.control = c
}
// get is like Get, but used when we already know object class.
//
// Use-case: in ZODB references are (pyclass, oid), so new ghost is created
......
......@@ -224,7 +224,7 @@ func (obj *Persistent) PDeactivate() {
// no constant load/unload on object access. XXX -> MRU cache?
// NOTE wcfs manages its objects explicitly and does not need this.
if cc := obj.jar.cache.cacheControl; cc != nil {
if cc := obj.jar.cache.control; cc != nil {
if !cc.WantEvict(obj.instance) {
return
}
......
......@@ -137,4 +137,5 @@ func TestPersistent(t *testing.T) {
// TODO activate again - refcnt++
// TODO deactivate - refcnt--
// TODO deactivate - state dropped
// TODO invalidate - must be on txn boundary; state dropped
}
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