mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-04 04:14:01 +01:00 
			
		
		
		
	Backport #33220 by TheFox0x7 Change SlowCacheThreshold to 30 milliseconds so it doesn't trigger on non memory cache Closes: https://github.com/go-gitea/gitea/issues/33190 Closes: https://github.com/go-gitea/gitea/issues/32657 Co-authored-by: TheFox0x7 <thefox0x7@gmail.com>
This commit is contained in:
		
							parent
							
								
									fcbbc24cc4
								
							
						
					
					
						commit
						31f2a325dc
					
				
							
								
								
									
										9
									
								
								modules/cache/cache.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								modules/cache/cache.go
									
									
									
									
										vendored
									
									
								
							@ -37,10 +37,15 @@ func Init() error {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
	testCacheKey       = "DefaultCache.TestKey"
 | 
			
		||||
	SlowCacheThreshold = 100 * time.Microsecond
 | 
			
		||||
	testCacheKey = "DefaultCache.TestKey"
 | 
			
		||||
	// SlowCacheThreshold marks cache tests as slow
 | 
			
		||||
	// set to 30ms per discussion: https://github.com/go-gitea/gitea/issues/33190
 | 
			
		||||
	// TODO: Replace with metrics histogram
 | 
			
		||||
	SlowCacheThreshold = 30 * time.Millisecond
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Test performs delete, put and get operations on a predefined key
 | 
			
		||||
// returns
 | 
			
		||||
func Test() (time.Duration, error) {
 | 
			
		||||
	if defaultCache == nil {
 | 
			
		||||
		return 0, fmt.Errorf("default cache not initialized")
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										3
									
								
								modules/cache/cache_test.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								modules/cache/cache_test.go
									
									
									
									
										vendored
									
									
								
							@ -43,7 +43,8 @@ func TestTest(t *testing.T) {
 | 
			
		||||
	elapsed, err := Test()
 | 
			
		||||
	assert.NoError(t, err)
 | 
			
		||||
	// mem cache should take from 300ns up to 1ms on modern hardware ...
 | 
			
		||||
	assert.Less(t, elapsed, time.Millisecond)
 | 
			
		||||
	assert.Positive(t, elapsed)
 | 
			
		||||
	assert.Less(t, elapsed, SlowCacheThreshold)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestGetCache(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user