How cachedb encode redis Key and Value?

I’m trying to setup unbound with cachedb and use redis as it’s backend

here is my unbound config:

server:
module-config: "cachedb validator iterator"
pidfile: "/run/unbound/unbound.pid"
verbosity: 4
log-queries: yes
logfile: "/var/log/unbound.log"

cachedb:
backend: redis
secret-seed: "mysecretseed2025"
redis-server-host: 127.0.0.1
redis-server-port: 6379
redis-logical-db: 0

when i try to do “dig” :

dig @[127.0.0.1](http://127.0.0.1) [www.vw.com](http://www.vw.com)

here what I got from redis-cli monitor:

1757153895.538580 [0 [127.0.0.1:45384](http://127.0.0.1:45384)] "GET" "C17FB95ECEC29435E6559BBB5EAB981D6FDC38E0AA338F30C7E8EB5D0652346B"
1757153897.048882 [0 [127.0.0.1:45384](http://127.0.0.1:45384)] "SET" "C17FB95ECEC29435E6559BBB5EAB981D6FDC38E0AA338F30C7E8EB5D0652346B" "\x00\x00\x81\x80\x00\x01\x00\x05\x00\x00\x00\x01\x03www\x02vw\x03com\x00\x00\x01\x00\x01\xc0\x0c\x00\x05\x00\x01\x00\x00\x0e\x0f\x00!\blive-usa\x04vwng\x0elighthouselabs\x02eu\x00\xc0(\x00\x05\x00\x01\x00\x00\a\a\x00\x16\x06vw-goa\tedgesuite\x03net\x00\xc0U\x00\x05\x00\x01\x00\x00T_\x00\x13\x04a995\x04dscr\x06akamai\xc0f\xc0w\x00\x01\x00\x01\x00\x00\x00\x14\x00\x04\xd2\xd2\x91\x93\xc0w\x00\x01\x00\x01\x00\x00\x00\x14\x00\x04\xd2\xd2\x91\x98\x00\x00)\x04\xd0\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00h\xbc\ni\x00\x00\x00\x00h\xbc\n}"

my question is: How unbound cachedb module “encode” that two field (key, value)?

regards

-wowon-

Hi wowon,

The function that calculates the hash is in the cachedb module at
https://github.com/NLnetLabs/unbound/blob/5588f66bdb8c8276b98a0fec4c9e04622999cfe3/cachedb/cachedb.c#L332

In short it is a hex representation of a hash that consists of the name, type, class and the backend secret.

Best regards,
-- Yorgos