Java – the best way to use a PostgreSQL database as a simple key value store

I was asked to use the PostgreSQL database, which will replace my current BerkeleyDB Although; I realized that this was not an ideal situation, it was beyond my control

So the question is... If you were asked to turn PostgreSQL into a key value repository, how would you do that while maximizing efficiency?

My values are byte arrays and my keys are strings. I can impose some restrictions on the length of these strings

I suppose I should use blob as the primary key column for my value and holding key, but when I venture into this journey, I am curious whether anyone in the stack overflow community has done so, or whether there are any specific "traps" that I should pay attention to

Solution

The extension to perform this operation correctly in PostgreSQL is hsstore It works like any other key value storage system you might expect Just load the extension Grammar is unique, but if you've ever used redis or Mongo, you'll get it soon Don't make it harder I understand that we often don't choose our tools and have to do it

http://www.postgresql.org/docs/9.1/static/hstore.html

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>