Caching: GetKey requires a namespace argument (#113180)

* Caching: GetKey requires a namespace argument

* GetKey: special case empty namespace
This commit is contained in:
Bruno
2025-11-03 12:22:36 -03:00
committed by GitHub
parent 14c45b6db2
commit 4cda8669a5
+7 -1
View File
@@ -84,7 +84,7 @@ func (s *OSSCachingService) HandleResourceRequest(ctx context.Context, req *back
var _ CachingService = &OSSCachingService{}
// GetKey creates a prefixed cache key and uses the internal `encoder` to encode the query into a string
func GetKey(prefix string, query interface{}) (string, error) {
func GetKey(namespace, prefix string, query interface{}) (string, error) {
keybuf := bytes.NewBuffer(nil)
encoder := &JSONEncoder{}
@@ -98,6 +98,12 @@ func GetKey(prefix string, query interface{}) (string, error) {
return "", err
}
// The namespace is empty only when this function is used by the legacy caching module.
// This case can be removed when the legacy caching module is not being used anymore.
if namespace != "" {
return strings.Join([]string{namespace, prefix, key}, ":"), nil
}
return strings.Join([]string{prefix, key}, ":"), nil
}