Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
cf423026
Commit
cf423026
authored
May 12, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update store cache
parent
93e8fa49
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
8 deletions
+19
-8
cache.go
store/cache.go
+1
-1
idp.go
store/idp.go
+4
-1
store.go
store/store.go
+1
-1
user.go
store/user.go
+4
-2
user_setting.go
store/user_setting.go
+4
-1
workspace_setting.go
store/workspace_setting.go
+5
-2
No files found.
store/cache.go
View file @
cf423026
...
...
@@ -5,5 +5,5 @@ import (
)
func
getUserSettingCacheKey
(
userID
int32
,
key
string
)
string
{
return
fmt
.
Sprintf
(
"%d-%s
-v1
"
,
userID
,
key
)
return
fmt
.
Sprintf
(
"%d-%s"
,
userID
,
key
)
}
store/idp.go
View file @
cf423026
...
...
@@ -70,7 +70,10 @@ func (s *Store) ListIdentityProviders(ctx context.Context, find *FindIdentityPro
func
(
s
*
Store
)
GetIdentityProvider
(
ctx
context
.
Context
,
find
*
FindIdentityProvider
)
(
*
storepb
.
IdentityProvider
,
error
)
{
if
find
.
ID
!=
nil
{
if
cache
,
ok
:=
s
.
idpCache
.
Load
(
*
find
.
ID
);
ok
{
return
cache
.
(
*
storepb
.
IdentityProvider
),
nil
identityProvider
,
ok
:=
cache
.
(
*
storepb
.
IdentityProvider
)
if
ok
{
return
identityProvider
,
nil
}
}
}
...
...
store/store.go
View file @
cf423026
...
...
@@ -13,7 +13,7 @@ type Store struct {
driver
Driver
workspaceSettingCache
sync
.
Map
// map[string]*storepb.WorkspaceSetting
userCache
sync
.
Map
// map[int]*User
userSettingCache
sync
.
Map
// map[string]*UserSetting
userSettingCache
sync
.
Map
// map[string]*
storepb.
UserSetting
idpCache
sync
.
Map
// map[int]*storepb.IdentityProvider
}
...
...
store/user.go
View file @
cf423026
...
...
@@ -131,9 +131,11 @@ func (s *Store) GetUser(ctx context.Context, find *FindUser) (*User, error) {
if
*
find
.
ID
==
SystemBotID
{
return
SystemBot
,
nil
}
if
cache
,
ok
:=
s
.
userCache
.
Load
(
*
find
.
ID
);
ok
{
return
cache
.
(
*
User
),
nil
user
,
ok
:=
cache
.
(
*
User
)
if
ok
{
return
user
,
nil
}
}
}
...
...
store/user_setting.go
View file @
cf423026
...
...
@@ -65,7 +65,10 @@ func (s *Store) ListUserSettings(ctx context.Context, find *FindUserSetting) ([]
func
(
s
*
Store
)
GetUserSetting
(
ctx
context
.
Context
,
find
*
FindUserSetting
)
(
*
storepb
.
UserSetting
,
error
)
{
if
find
.
UserID
!=
nil
{
if
cache
,
ok
:=
s
.
userSettingCache
.
Load
(
getUserSettingCacheKey
(
*
find
.
UserID
,
find
.
Key
.
String
()));
ok
{
return
cache
.
(
*
storepb
.
UserSetting
),
nil
userSetting
,
ok
:=
cache
.
(
*
storepb
.
UserSetting
)
if
ok
{
return
userSetting
,
nil
}
}
}
...
...
store/workspace_setting.go
View file @
cf423026
...
...
@@ -80,7 +80,10 @@ func (s *Store) ListWorkspaceSettings(ctx context.Context, find *FindWorkspaceSe
func
(
s
*
Store
)
GetWorkspaceSetting
(
ctx
context
.
Context
,
find
*
FindWorkspaceSetting
)
(
*
storepb
.
WorkspaceSetting
,
error
)
{
if
cache
,
ok
:=
s
.
workspaceSettingCache
.
Load
(
find
.
Name
);
ok
{
return
cache
.
(
*
storepb
.
WorkspaceSetting
),
nil
workspaceSetting
,
ok
:=
cache
.
(
*
storepb
.
WorkspaceSetting
)
if
ok
{
return
workspaceSetting
,
nil
}
}
list
,
err
:=
s
.
ListWorkspaceSettings
(
ctx
,
find
)
...
...
@@ -91,7 +94,7 @@ func (s *Store) GetWorkspaceSetting(ctx context.Context, find *FindWorkspaceSett
return
nil
,
nil
}
if
len
(
list
)
>
1
{
return
nil
,
errors
.
Errorf
(
"
F
ound multiple workspace settings with key %s"
,
find
.
Name
)
return
nil
,
errors
.
Errorf
(
"
f
ound multiple workspace settings with key %s"
,
find
.
Name
)
}
return
list
[
0
],
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment