* cache: add sharded cache implementation
Add Cache impl and a few tests. This cache is 256-way sharded, mainly
so each shard has it's own lock. The main cache structure is a readonly
jump plane into the right shard.
This should remove the single lock contention on the main lock and
provide more concurrent throughput - Obviously this hasn't been tested
or measured.
The key into the cache was made a uint32 (hash.fnv) and the hashing op
is not using strings.ToLower anymore remove any GC in that code path.
* here too
* Minimum shard size
* typos
* blurp
* small cleanups no defer
* typo
* Add freq based on Johns idea
* cherry-pick conflict resolv
* typo
* update from early code review from john
* add prefetch to the cache
* mw/cache: add prefetch
* remove println
* remove comment
* Fix tests
* Test prefetch in setup
* Add start of cache
* try add diff cache options
* Add hacky testcase
* not needed
* allow the use of a percentage for prefetch
If the TTL falls below xx% do a prefetch, if the record was popular.
Some other fixes and correctly prefetch only popular records.
* Replace go-cache with golang-lru
This fix replace go-cache with golang-lru, as is specified in 335.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
* Move cache initialization to setup
This commit move cache initialization to setup in dnssec middleware.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
* Add a setup test for middleware/file
This fix adds a setup test for middleware/file so that there is
a basic coverage for the Corefile processing of middleware/file.
This fix is related to 308 (Will look into it).
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
* middleware/file: use helper function for test
Fixup setup_test.go and use the test.TempFile function to make things
somewhat shorter.
Use clean up the use of testing.T in TempFile - it is not used.
Move all (almost all) Go files in middleware into their
own packages. This makes for better naming and discoverability.
Lot of changes elsewhere to make this change.
The middleware.State was renamed to request.Request which is better,
but still does not cover all use-cases. It was also moved out middleware
because it is used by `dnsserver` as well.
A pkg/dnsutil packages was added for shared, handy, dns util functions.
All normalize functions are now put in normalize.go
* Make CoreDNS a server type plugin for Caddy
Remove code we don't need and port all middleware over. Fix all tests
and rework the documentation.
Also make `go generate` build a caddy binary which we then copy into
our directory. This means `go build`-builds remain working as-is.
And new etc instances in each etcd test for better isolation.
Fix more tests and rework test.Server with the newer support Caddy offers.
Fix Makefile to support new mode of operation.