mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-20 05:00:01 +02:00
Add commit count caching (#2774)
* Add commit count caching * Small refactoring * Add different key prefix for refs and commits * Add configuratuion option to allow to change caching time or disable it
This commit is contained in:
parent
3ab580c8d6
commit
eca05b09aa
10 changed files with 153 additions and 28 deletions
|
@ -258,6 +258,17 @@ func (repo *Repository) APIFormat(mode AccessMode) *api.Repository {
|
|||
return repo.innerAPIFormat(mode, false)
|
||||
}
|
||||
|
||||
// GetCommitsCountCacheKey returns cache key used for commits count caching.
|
||||
func (repo *Repository) GetCommitsCountCacheKey(contextName string, isRef bool) string {
|
||||
var prefix string
|
||||
if isRef {
|
||||
prefix = "ref"
|
||||
} else {
|
||||
prefix = "commit"
|
||||
}
|
||||
return fmt.Sprintf("commits-count-%d-%s-%s", repo.ID, prefix, contextName)
|
||||
}
|
||||
|
||||
func (repo *Repository) innerAPIFormat(mode AccessMode, isParent bool) *api.Repository {
|
||||
var parent *api.Repository
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue