peterbourgon / diskv

A disk-backed key-value store.
http://godoc.org/github.com/peterbourgon/diskv
MIT License
1.4k stars 102 forks source link

Best way to create multiple keys for same value? #45

Closed shah closed 6 years ago

shah commented 6 years ago

@peterbourgon what's the best way to accomplish value 'aliases' or 'links' using multiple keys pointing to the same value? For example, I have a JSON file to store, it has a canonical name (the 'key'). Then, I might have several other aliases or keys, e.g. tags, that I would like to use to lookup the same value (meaning I could use the primary key or any number of secondary keys).

I was thinking this could be implemented using file systems symlinks for the secondary keys but wasn't sure how to support that in diskv. Thoughts?

This is a great library by the way, I love the idea of a KV store with a simple way to get access to the files. Excellent idea.

peterbourgon commented 6 years ago

The easiest and best way is to implement this at the application layer.

key=foo value={"data":{...}}
key=bar value={"ref":"foo"}
key=baz value={"ref":"foo"}
shah commented 6 years ago

Great idea @peterbourgon that should work. Thanks!