mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-08 21:47:17 +08:00
feat: cache optimize
This commit is contained in:
parent
0ea06a3880
commit
a736022c8e
@ -17,6 +17,8 @@ package third
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
"github.com/OpenIMSDK/tools/mw/specialerror"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
@ -78,6 +80,12 @@ func Start(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
specialerror.AddErrHandler(func(err error) errs.CodeError {
|
||||
if o.IsNotFound(err) {
|
||||
return errs.ErrRecordNotFound
|
||||
}
|
||||
return nil
|
||||
})
|
||||
third.RegisterThirdServer(server, &thirdServer{
|
||||
apiURL: apiURL,
|
||||
thirdDatabase: controller.NewThirdDatabase(cache.NewMsgCacheModel(rdb), db),
|
||||
|
||||
3
pkg/common/db/cache/meta_cache.go
vendored
3
pkg/common/db/cache/meta_cache.go
vendored
@ -18,6 +18,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/OpenIMSDK/tools/mw/specialerror"
|
||||
"time"
|
||||
|
||||
"github.com/dtm-labs/rockscache"
|
||||
@ -209,7 +210,7 @@ func batchGetCache2[T any, K comparable](
|
||||
return fns(ctx, key)
|
||||
})
|
||||
if err != nil {
|
||||
if errs.ErrRecordNotFound.Is(err) {
|
||||
if errs.ErrRecordNotFound.Is(specialerror.ErrCode(errs.Unwrap(err))) {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user