Is there a data-structure/model for storing a value at an arbitrary URI-based key, and then if null, backing down to a less specific path/domain? i.e.
SET example.com "hello"
SET a.example.com/foo "world"
GET example.com => "hello"
GET example.com/foo => "hello"
GET a.example.com/foo/bar => "world"
Value is simply a serialized JSON object; I don't need to do any list operations on it.
Currently, I'm using node.js/restify backed by redis (although I am open to other datastores). I realize I could have a flat key-value store, and loop through all subpaths/domains, but that feels inefficient with a dozen potentially empty calls to the datastore.
You can do a binary search on a failed key lookup to find the most specific matching URI. For example, you've got a depth-8 URI; start by checking for an exact match, if this fails then check the depth-4 URI; if this fails then check the depth-2 URI, else check the depth-6 URI; assume in this case that the depth-4 and depth-6 lookups succeeded, next you'll do a depth-7 lookup, if this succeeds then return the depth-7 value, else return the depth-6 value.
As an alternative, via Google I found a trie implementation for leveldb that might do the trick, but in general there don't appear to be very many database trie implementations.