more caching in-client

This commit is contained in:
6543 2022-07-27 15:39:46 +02:00
parent b2b22872a2
commit a8afb372dd
No known key found for this signature in database
GPG key ID: C99B82E40B027BAE
11 changed files with 95 additions and 80 deletions

View file

@ -1,5 +1,7 @@
package gitea
import "time"
type FileResponse struct {
Exists bool
ETag []byte
@ -10,3 +12,18 @@ type FileResponse struct {
func (f FileResponse) IsEmpty() bool {
return len(f.Body) != 0
}
type BranchTimestamp struct {
Branch string
Timestamp time.Time
}
var (
// defaultBranchCacheTimeout specifies the timeout for the default branch cache. It can be quite long.
defaultBranchCacheTimeout = 15 * time.Minute
// branchExistenceCacheTimeout specifies the timeout for the branch timestamp & existence cache. It should be shorter
// than fileCacheTimeout, as that gets invalidated if the branch timestamp has changed. That way, repo changes will be
// picked up faster, while still allowing the content to be cached longer if nothing changes.
branchExistenceCacheTimeout = 5 * time.Minute
)