mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 18:23:13 -04:00 
			
		
		
		
	lower cache min limit (#2065)
This commit is contained in:
		
				
					committed by
					
						 Miek Gieben
						Miek Gieben
					
				
			
			
				
	
			
			
			
						parent
						
							a21755479d
						
					
				
				
					commit
					684c35d56b
				
			
							
								
								
									
										19
									
								
								plugin/cache/README.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								plugin/cache/README.md
									
									
									
									
										vendored
									
									
								
							| @@ -52,11 +52,12 @@ cache [TTL] [ZONES...] { | ||||
|  | ||||
| ## Capacity and Eviction | ||||
|  | ||||
| When specifying **CAPACITY**, the minimum cache capacity is 131,072.  Specifying a lower value will be | ||||
| ignored. Specifying a **CAPACITY** of zero does not disable the cache. | ||||
|  | ||||
| Eviction is done per shard - i.e. when a shard reaches capacity, items are evicted from that shard.  Since shards don't fill up perfectly evenly, evictions will occur before the entire cache reaches full capacity. Each shard capacity is equal to the total cache size / number of shards (256). | ||||
| If **CAPACITY** is not specified, the default cache size is 10,000 per cache. The minimum allowed cache size is 1024. | ||||
|  | ||||
| Eviction is done per shard. In effect, when a shard reaches capacity, items are evicted from that shard. | ||||
| Since shards don't fill up perfectly evenly, evictions will occur before the entire cache reaches full capacity. | ||||
| Each shard capacity is equal to the total cache size / number of shards (256). Eviction is random, not TTL based. | ||||
| Entries with 0 TTL will remain in the cache until randomly evicted when the shard reaches capacity. | ||||
|  | ||||
| ## Metrics | ||||
|  | ||||
| @@ -89,3 +90,13 @@ Proxy to Google Public DNS and only cache responses for example.org (or below). | ||||
|     cache example.org | ||||
| } | ||||
| ~~~ | ||||
|  | ||||
| Enable caching for all zones, keep a positive cache size of 5000 and a negative cache size of 2500: | ||||
|  ~~~ corefile | ||||
|  . { | ||||
|      cache { | ||||
|          success 5000 | ||||
|          denial 2500 | ||||
|     } | ||||
|  } | ||||
|  ~~~ | ||||
							
								
								
									
										4
									
								
								plugin/pkg/cache/cache.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								plugin/pkg/cache/cache.go
									
									
									
									
										vendored
									
									
								
							| @@ -31,8 +31,8 @@ type shard struct { | ||||
| // New returns a new cache. | ||||
| func New(size int) *Cache { | ||||
| 	ssize := size / shardSize | ||||
| 	if ssize < 512 { | ||||
| 		ssize = 512 | ||||
| 	if ssize < 4 { | ||||
| 		ssize = 4 | ||||
| 	} | ||||
|  | ||||
| 	c := &Cache{} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user