Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix registry caching #2427

Merged
merged 1 commit into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-registry-caching.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: fix registry caching

We now cache space lookups per user.

https://github.com/cs3org/reva/pull/2427
10 changes: 7 additions & 3 deletions internal/grpc/services/gateway/storageprovidercache.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ type cachedRegistryClient struct {
func (c *cachedRegistryClient) ListStorageProviders(ctx context.Context, in *registry.ListStorageProvidersRequest, opts ...grpc.CallOption) (*registry.ListStorageProvidersResponse, error) {
cache := c.caches[listproviders]

key := sdk.DecodeOpaqueMap(in.Opaque)["storage_id"]
user := ctxpkg.ContextMustGetUser(ctx)

storageID := sdk.DecodeOpaqueMap(in.Opaque)["storage_id"]

key := user.GetId().GetOpaqueId() + storageID
if key != "" {
s := &registry.ListStorageProvidersResponse{}
if err := pullFromCache(cache, key, s); err == nil {
Expand All @@ -176,9 +180,9 @@ func (c *cachedRegistryClient) ListStorageProviders(ctx context.Context, in *reg
switch {
case err != nil:
return nil, err
case resp.Status.Code != rpc.Code_CODE_OK && resp.Status.Code != rpc.Code_CODE_NOT_FOUND:
case resp.Status.Code != rpc.Code_CODE_OK:
return resp, nil
case key == "":
case storageID == "":
return resp, nil
default:
return resp, pushToCache(cache, key, resp)
Expand Down