peterbourgon / diskv

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

does diskv support range query? #6

Closed ifq closed 11 years ago

ifq commented 11 years ago

I'm look for a embedded db, and I feel diskv might be a choise. But I need to do some range query.

my scene is: I have some files, about 50000, each file have properties like size, time, tags which stored in db. I need to range query them by time or tags.

Does diskv support this? or in key-value db, how should I achieve this ?

thank you.

peterbourgon commented 11 years ago

diskv is primarily a content-addressable-store, with very basic support for key ordering via the Index functionality.

If you want to do a range query over some property, you can construct your keys so that they contain this information, and write a custom LessFunction which sorts them by the property you care about.

Of course, this only allows one sort-order per diskv instance. If you need arbitrary ordering, it's probably a good sign that need a more sophisticated persistence layer than diskv.

Does that help?

ifq commented 11 years ago

thank you. That helps. may be I need to reconsider my approach.