What kind of data types can be stored in badger?

Hi, I am looking for a key value store for one of my projects. I am unsure whether I should use redis or badger. I have seen redis has a hash data type that might fit my needs. Is there something similar in badger?

I want to use the kv store, to store client certificates and some additional metadata about them. For example, I want to associate roles with the certs to have a way to perform authorization for specific actions.

The API takes []byte as both key and value, you can put pretty much any serialized value in there.

Badger is obviously a embedded DB very unlike Redis which is a server. Badger has excellent support for iterating over all results for a prefix, but if you only have 1:1 key:value then you won’t be using that. It is not a RDBMS so you won’t be able to associate some value with multiple keys without doing it yourself in application code.

Dgraph stores protobufs as values and has strings as keys, mostly.

edit: with respect to your question about the hash type, badger does not have a hash type, nor does it have types at all, it is just []byte. Basically all you get is Set(key,value), Delete(key), Get(key) value and GetPrefix(pfx) []values (made up function signatures for simplicity)

1 Like