liamzebedee
liamzebedee

Reputation: 14490

How do I choose a database?

I need a comparison table of some sort for database varieties (MySQL, SQLite etc.). I can't find one.

My use case is, I am implementing storage of objects in a distributed hash table. I need a database solution that is:

I will be programming in Go.

As I understand, I believe I need what is called a Document Orientated Database, because I am storing objects, identified by keys.

EDIT: While I am implementing a DHT, I will also be storing metadata about the objects, such as access counts etc. It would also be preferable to have TLL (time to live)

Upvotes: 0

Views: 137

Answers (1)

asthasr
asthasr

Reputation: 9407

"Document oriented" isn't what I would call what you want. I think you want a "key-value store," which is probably the simplest type of NoSQL to use. You can do something like this:

> set "key" value
"OK"
> get "key"
"value"

As such, I recommend redis, which I find pleasantly "light" compared to the heavier and more structured alternatives. You can try it at Try Redis, which is a functional interactive shell.


Edit: your comment, as well as your edit, continue to recommend Redis. Redis has TTL, in the form of two commands: expire, which takes a number of seconds, and expireat, which takes a Unix timestamp. In addition, it allows hashes, which meet your needs (as I understand them):

> hmset POST:dd68f250-c3f2-11e1-9b21-0800200c9a66 _timestamp 1341198420 title "An Example" content "This is an example of a representation of a blog post (or something) in Redis."
"OK"
> hgetall POST:dd68f250-c3f2-11e1-9b21-0800200c9a66
{"_timestamp":"1341198420","title":"An Example","content":"This is an example of a representation of a blog post (or something) in Redis."}
> expire POST:dd68f250-c3f2-11e1-9b21-0800200c9a66 60
true
> ttl POST:dd68f250-c3f2-11e1-9b21-0800200c9a66
53

Upvotes: 2

Related Questions