Note: This is a simple key-value store over HTTP, and not very useful except for quick prototyping. For a proper go embedded DB, take a look at gobble-db.
An extremely simple and lightweight HTTP key-value store. Written in go using fiber, because it's fast.
It can also use a Postgres DB as storage, while still having the same nice & simple HTTP key-value store.
Because I needed something simple to store/access data on a local server (for a project), without having to deal with an SQL or other database.
Basically, I wanted to be able to do this:
go run main.go # Running on X.X.X.X:6010
fetch(`http://X.X.X.X:6010/set/example/${key}/${data}`)
fetch(f"http://X.X.X.X:6010/get/example/{key}") // data as text body
Then I also thought that it'd be nice to be able to use an SQL DB as storage for the key-value store (mostly to allow using a cloud SQL DB), so now it can also use a Postgres DB as storage.
It's very, very simple.
-
Download, extract, open folder.
-
go mod tidy
, thengo run .
-
Make http requests. Routes:
set (replaces value): GET /set/<category>/<key>/<value>/ POST /set/<category>/<key>/ (raw POST body is used as value) add (appends to value): GET /add/<category>/<key>/<value>/ POST /add/<category>/<key>/ (raw POST body is used as value) get: GET /get/<category>/<key>/ (gets stored value as response text) del (deletes value): GET /del/<category>/<key>/
# Examples: curl http://127.0.0.1:5000/set/example/somekey/somevalue/ curl http://127.0.0.1:5000/get/example/somekey/ # somevalue
Yes.