Commit 16db7baf authored by Kirill Smelkov's avatar Kirill Smelkov

go/zodb: Don't automatically inherit IStorageDriver methods

storage is a wrapper that turns IStorageDriver into IStorage. It will
have some logic around almost all IStorageDriver methods. So don't
automatically inherit driver methods not to miss some.
parent 0b488149
......@@ -115,8 +115,8 @@ func OpenStorage(ctx context.Context, zurl string, opt *OpenOptions) (IStorage,
}
return &storage{
IStorageDriver: storDriver,
l1cache: cache,
driver: storDriver,
l1cache: cache,
}, nil
}
......@@ -127,20 +127,34 @@ func OpenStorage(ctx context.Context, zurl string, opt *OpenOptions) (IStorage,
// it provides a small cache on top of raw storage driver to implement prefetch
// and other storage-independed higher-level functionality.
type storage struct {
IStorageDriver
driver IStorageDriver
l1cache *Cache // can be =nil, if opened with NoCache
}
func (s *storage) URL() string { return s.driver.URL() }
func (s *storage) Iterate(ctx context.Context, tidMin, tidMax Tid) ITxnIterator {
return s.driver.Iterate(ctx, tidMin, tidMax)
}
func (s *storage) Close() error {
return s.driver.Close()
}
// loading goes through cache - this way prefetching can work
func (s *storage) LastTid(ctx context.Context) (Tid, error) {
return s.driver.LastTid(ctx)
}
func (s *storage) Load(ctx context.Context, xid Xid) (*mem.Buf, Tid, error) {
// XXX here: offload xid validation from cache and driver ?
// XXX here: offload wrapping err -> OpError{"load", err} ?
if s.l1cache != nil {
return s.l1cache.Load(ctx, xid)
} else {
return s.IStorageDriver.Load(ctx, xid)
return s.driver.Load(ctx, xid)
}
}
......
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