MM-59947: Remove the remaining **model.User special casing (#28707)
We remove the remaining special casing for **model.User and add unit tests to lock in the behavior. Additional load tests were done locally to confirm there are no hidden code paths left out. https://mattermost.atlassian.net/browse/MM-59947 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
bef486ab00
Коммит
a190fe8503
25
server/platform/services/cache/redis.go
поставляемый
25
server/platform/services/cache/redis.go
поставляемый
@@ -169,22 +169,6 @@ func (r *Redis) Get(key string, value any) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// This is ugly and makes the cache package aware of the model package.
|
||||
// But this is due to 2 things.
|
||||
// 1. The msgp package works on methods on structs rather than functions.
|
||||
// 2. Our cache interface passes pointers to empty pointers, and not pointers
|
||||
// to values. This is mainly how all our model structs are passed around.
|
||||
// It might be technically possible to use values _just_ for hot structs
|
||||
// like these and then return a pointer while returning from the cache function,
|
||||
// but it will make the codebase inconsistent, and has some edge-cases to take care of.
|
||||
switch v := value.(type) {
|
||||
case **model.User:
|
||||
var u model.User
|
||||
_, err := u.UnmarshalMsg(bytesVal)
|
||||
*v = &u
|
||||
return err
|
||||
}
|
||||
|
||||
// Slow path for other structs.
|
||||
return msgpack.Unmarshal(bytesVal, value)
|
||||
}
|
||||
@@ -256,15 +240,6 @@ func (r *Redis) GetMulti(keys []string, values []any) []error {
|
||||
continue
|
||||
}
|
||||
|
||||
switch v := values[i].(type) {
|
||||
case **model.User:
|
||||
var u model.User
|
||||
_, err := u.UnmarshalMsg(bytesVal)
|
||||
*v = &u
|
||||
errs[i] = err
|
||||
continue
|
||||
}
|
||||
|
||||
// Slow path for other structs.
|
||||
errs[i] = msgpack.Unmarshal(bytesVal, values[i])
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user