Skip to content

dnsdist: add generic object cache#17561

Draft
esensar wants to merge 2 commits into
PowerDNS:masterfrom
esensar:feature/dnsdist-generic-object-cache
Draft

dnsdist: add generic object cache#17561
esensar wants to merge 2 commits into
PowerDNS:masterfrom
esensar:feature/dnsdist-generic-object-cache

Conversation

@esensar

@esensar esensar commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Short description

This adds a new object usable from Lua - GenericCache - which can be used to store any values under string keys and retrieve them later on.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • read and accepted the Developer Certificate of Origin document, including the AI Policy, and added a "Signed-off-by" to my commits
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

Sponsored by Quad9

@esensar

esensar commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

This was mostly implemented to work with: #17387, but it could be useful otherwise too I think.
The idea is to also integrate it into redis clients, since delays introduced by redis lookups would be too slow for most users.
That is already implemented in our testing fork, with support for result caching, copy caching (copying all redis values that could be found by the specified lookup action), filtering (using the object cache as a set of keys, but also bloom and cuckoo filters) and negative caching.
This is just a small initial PR, to check if this is acceptable in the context of dnsdist.

Signed-off-by: Ensar Sarajčić <dev@ensarsarajcic.com>
@esensar esensar force-pushed the feature/dnsdist-generic-object-cache branch from 579fffb to b81fd63 Compare June 11, 2026 10:58
Signed-off-by: Ensar Sarajčić <dev@ensarsarajcic.com>
@rgacogne

Copy link
Copy Markdown
Member

Thanks for opening this PR! I'll do a high-level review soon to see if this is something that are interested in merging, please don't spend more time on this until we have reached a decision!

@esensar

esensar commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for opening this PR! I'll do a high-level review soon to see if this is something that are interested in merging, please don't spend more time on this until we have reached a decision!

Thanks. That makes sense.

@coveralls

coveralls commented Jun 11, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 27342075016

Coverage decreased (-0.1%) to 70.976%

Details

  • Coverage decreased (-0.1%) from the base build.
  • Patch coverage: 357 uncovered changes across 6 files (31 of 388 lines covered, 7.99%).
  • 43 coverage regressions across 12 files.

Uncovered Changes

File Changed Covered %
pdns/dnsdistdist/generic-cache.hh 235 0 0.0%
pdns/dnsdistdist/dnsdist-lua-bindings-cache.cc 74 10 13.51%
pdns/dnsdistdist/dnsdist-carbon.cc 29 1 3.45%
pdns/dnsdistdist/dnsdist-configuration-yaml.cc 20 5 25.0%
pdns/dnsdistdist/dnsdist-web.cc 28 14 50.0%
pdns/dnsdistdist/generic-cache-interface.hh 1 0 0.0%
Total (7 files) 388 31 7.99%

Coverage Regressions

43 previously-covered lines in 12 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
pdns/signingpipe.cc 10 82.12%
pdns/recursordist/test-syncres_cc1.cc 5 80.24%
pdns/auth-secondarycommunicator.cc 4 57.94%
pdns/packethandler.cc 4 69.08%
pdns/shuffle.cc 4 53.93%
pdns/iputils.hh 3 76.03%
pdns/misc.cc 3 61.95%
pdns/misc.hh 3 86.92%
modules/godbcbackend/sodbc.cc 2 69.31%
pdns/recursordist/aggressive_nsec.cc 2 66.2%

Coverage Stats

Coverage Status
Relevant Lines: 171267
Covered Lines: 133200
Line Coverage: 77.77%
Relevant Branches: 81820
Covered Branches: 46430
Branch Coverage: 56.75%
Branches in Coverage %: Yes
Coverage Strength: 6615718.85 hits per line

💛 - Coveralls

@rgacogne

Copy link
Copy Markdown
Member

I'm wondering if we could somehow merge this work with the one happening in #16692, by implementing a generic enough cache class and then specializing it for DNS packets. That way we would (hopefully) avoid duplicating a lot of Lua bindings / YAML settings, if we manage to make them generic enough to apply to the packet cache and this generic object cache. Or am I too optimistic? :-)

@esensar

esensar commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

Well it seems like it could be possible, considering this cache is supposed to be generic. I need to take a deeper look into that PR, but at first glance it seems possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants