mirror of
				https://github.com/gohugoio/hugo.git
				synced 2024-05-11 05:54:58 +00:00 
			
		
		
		
	
							
								
								
									
										4
									
								
								cache/namedmemcache/named_cache.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								cache/namedmemcache/named_cache.go
									
									
									
									
										vendored
									
									
								
							@@ -30,7 +30,7 @@ type Cache struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type cacheEntry struct {
 | 
			
		||||
	value interface{}
 | 
			
		||||
	value any
 | 
			
		||||
	err   error
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -55,7 +55,7 @@ func (c *Cache) Clear() {
 | 
			
		||||
// create will be called and cached.
 | 
			
		||||
// This method is thread safe. It also guarantees that the create func for a given
 | 
			
		||||
// key is invoked only once for this cache.
 | 
			
		||||
func (c *Cache) GetOrCreate(key string, create func() (interface{}, error)) (interface{}, error) {
 | 
			
		||||
func (c *Cache) GetOrCreate(key string, create func() (any, error)) (any, error) {
 | 
			
		||||
	c.mu.RLock()
 | 
			
		||||
	entry, found := c.cache[key]
 | 
			
		||||
	c.mu.RUnlock()
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								cache/namedmemcache/named_cache_test.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								cache/namedmemcache/named_cache_test.go
									
									
									
									
										vendored
									
									
								
							@@ -28,7 +28,7 @@ func TestNamedCache(t *testing.T) {
 | 
			
		||||
	cache := New()
 | 
			
		||||
 | 
			
		||||
	counter := 0
 | 
			
		||||
	create := func() (interface{}, error) {
 | 
			
		||||
	create := func() (any, error) {
 | 
			
		||||
		counter++
 | 
			
		||||
		return counter, nil
 | 
			
		||||
	}
 | 
			
		||||
@@ -58,8 +58,8 @@ func TestNamedCacheConcurrent(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	cache := New()
 | 
			
		||||
 | 
			
		||||
	create := func(i int) func() (interface{}, error) {
 | 
			
		||||
		return func() (interface{}, error) {
 | 
			
		||||
	create := func(i int) func() (any, error) {
 | 
			
		||||
		return func() (any, error) {
 | 
			
		||||
			return i, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user