[#676] services/container: Cache the results of read operations

In previous implementation Container service handlers didn't cache the
results of `Get` / `GetEACL` / `List` operations. As a consequence of this,
high load on the service caused neo-go client's connection errors. To avoid
this there is a need to use cache. Object service already uses `Get` and
`GetEACL` caches.

Implement cache of `List` results. Share already implemented cache of Object
service with the Container one. Provide new instance of read-only container
storage (defined as an interface)to morph executor's constructor on which
container service is based. Write operations remained unchanged.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-08-30 14:16:41 +03:00 committed by Alex Vanin
parent c54f524df9
commit e738699fcc
5 changed files with 115 additions and 30 deletions

View file

@ -364,20 +364,6 @@ func initObjectService(c *cfg) {
respSvc,
)
var (
eACLSource eacl.Source
eACLFetcher = &morphEACLFetcher{
w: c.cfgObject.cnrClient,
}
)
if c.cfgMorph.disableCache {
eACLSource = eACLFetcher
} else {
// use RPC node as source of eACL (with caching)
eACLSource = newCachedEACLStorage(eACLFetcher)
}
aclSvc := acl.New(
acl.WithSenderClassifier(
acl.NewSenderClassifier(
@ -392,7 +378,7 @@ func initObjectService(c *cfg) {
acl.WithNextService(signSvc),
acl.WithLocalStorage(ls),
acl.WithEACLValidatorOptions(
eacl.WithEACLSource(eACLSource),
eacl.WithEACLSource(c.cfgObject.eaclSource),
eacl.WithLogger(c.log),
),
acl.WithNetmapState(c.cfgNetmap.state),