-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add context cache as a request level cache #22294
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
901cdb2
Add context cache support
lunny 94a7ddf
Fix test
lunny 1c89c15
Merge branch 'main' into lunny/context_cache
lunny 109979d
replace template function
lunny 96b7e2d
Fix bug
lunny e455e8b
Fix bug
lunny 4a2f3fe
Fix bug
lunny f1e7b34
Merge branch 'main' into lunny/context_cache
lunny 1f68f88
Fix bug
lunny 4727355
Fix bug
lunny 89600f7
Add unit test
lunny 696e0d3
merge main branch
lunny b0f0267
merge main branch
lunny 728ae6c
Fix multiple goroutines problem
lunny 57187ef
merge main branch
lunny 35221d6
Merge branch 'main' into lunny/context_cache
lunny 5a1fad6
a new generic function
lunny 8a3294e
Merge branch 'main' into lunny/context_cache
lunny bb279f6
make context cache data private
lunny 296b9c2
Merge branch 'main' into lunny/context_cache
lunny 3f2869d
some slight changes
lunny d25b6b5
Add some comment and test
lunny a98791c
merge main branch
lunny 3b26a55
Fix template wrong ref
lunny 95375f7
Merge branch 'main' into lunny/context_cache
lunny 669d5c3
merge main branch
lunny 1474785
merge main branch
lunny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"testing" | ||
|
||
avatars_model "code.gitea.io/gitea/models/avatars" | ||
"code.gitea.io/gitea/models/db" | ||
system_model "code.gitea.io/gitea/models/system" | ||
"code.gitea.io/gitea/modules/setting" | ||
|
||
|
@@ -16,15 +17,15 @@ import ( | |
const gravatarSource = "https://secure.gravatar.com/avatar/" | ||
|
||
func disableGravatar(t *testing.T) { | ||
err := system_model.SetSettingNoVersion(system_model.KeyPictureEnableFederatedAvatar, "false") | ||
err := system_model.SetSettingNoVersion(db.DefaultContext, system_model.KeyPictureEnableFederatedAvatar, "false") | ||
assert.NoError(t, err) | ||
err = system_model.SetSettingNoVersion(system_model.KeyPictureDisableGravatar, "true") | ||
err = system_model.SetSettingNoVersion(db.DefaultContext, system_model.KeyPictureDisableGravatar, "true") | ||
assert.NoError(t, err) | ||
system_model.LibravatarService = nil | ||
} | ||
|
||
func enableGravatar(t *testing.T) { | ||
err := system_model.SetSettingNoVersion(system_model.KeyPictureDisableGravatar, "false") | ||
err := system_model.SetSettingNoVersion(db.DefaultContext, system_model.KeyPictureDisableGravatar, "false") | ||
assert.NoError(t, err) | ||
setting.GravatarSource = gravatarSource | ||
err = system_model.Init() | ||
|
@@ -47,11 +48,11 @@ func TestSizedAvatarLink(t *testing.T) { | |
|
||
disableGravatar(t) | ||
assert.Equal(t, "/testsuburl/assets/img/avatar_default.png", | ||
avatars_model.GenerateEmailAvatarFastLink("[email protected]", 100)) | ||
avatars_model.GenerateEmailAvatarFastLink(db.DefaultContext, "[email protected]", 100)) | ||
|
||
enableGravatar(t) | ||
assert.Equal(t, | ||
"https://secure.gravatar.com/avatar/353cbad9b58e69c96154ad99f92bedc7?d=identicon&s=100", | ||
avatars_model.GenerateEmailAvatarFastLink("[email protected]", 100), | ||
avatars_model.GenerateEmailAvatarFastLink(db.DefaultContext, "[email protected]", 100), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it harmful to use
db.DefaultContext
now because this uses a context cache without request lifetime?db.DefaultContext
is valid for the whole application lifetime. I try to replace #22491 but theredb.DefaultContext
would be used sometimes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we use
db.DefaultContext
then there is no request level cache will be triggered. The context cache will be ignored here.