WebAssembly / wasi-keyvalue

31 stars 11 forks source link

Non string keys #8

Open olanod opened 1 year ago

olanod commented 1 year ago

There are many use-cases that would benefit from having a key-value store where keys are not strings but opaque bytes, would there be a particular reason why the type key needs to be string?

Mossaka commented 1 year ago

I have experimented with a few keyvalue stores (dynamodb, redis, azure cosmos db) and they all seem to accept key as strings. Could you please list a few use cases where the keys are non-strings? I am happy to change the key type

olanod commented 1 year ago

I'd use it for embedded use cases for example, sometimes directly store the bytes or abstract it to use data structures that are encoded automatically to an efficient representation.

sunfishcode commented 1 year ago

Another challenge with byte sequences is that it's not possible to transcode plain bytes to key-value stores which use different character encodings. It looks to me like string is a better fit for the use cases and implementations that originally motivated wasi-keyvalue.

olanod commented 1 year ago

What about supporting both with keys being something like an enum?

sunfishcode commented 1 year ago

With an enum, using wasi-keyvalue with a backend that needs strings would have to always fail when given bytes.

Could you say more about your use case? What kinds of embedded programs would use an external key-value store? What backends would you expect to be used to implement the interface?