All Projects → schollz → Jsonstore

schollz / Jsonstore

Licence: mit
Simple thread-safe in-memory JSON key-store with persistent backend

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to Jsonstore

World Currencies
Currency information in JSON
Stars: ✭ 114 (-3.39%)
Mutual labels:  json
Fetch Plus
🐕 Fetch+ is a convenient Fetch API replacement with first-class middleware support.
Stars: ✭ 116 (-1.69%)
Mutual labels:  json
Netclient Ios
Versatile HTTP Networking in Swift
Stars: ✭ 117 (-0.85%)
Mutual labels:  json
Just Dashboard
📊 📋 Dashboards using YAML or JSON files
Stars: ✭ 1,511 (+1180.51%)
Mutual labels:  json
Zoya
Truly highly composable logging utility
Stars: ✭ 116 (-1.69%)
Mutual labels:  json
Captagent
100% Open-Source Packet Capture Agent for HEP
Stars: ✭ 116 (-1.69%)
Mutual labels:  json
Dynamodb Json
DynamoDB json util to load and dump strings of Dynamodb json format to python object and vise-versa
Stars: ✭ 114 (-3.39%)
Mutual labels:  json
Qqlight Websocket
QQLight机器人WebSocket-RPC插件,让你能够使用任何语言编写QQ机器人程序
Stars: ✭ 118 (+0%)
Mutual labels:  json
Kafka Connect Spooldir
Kafka Connect connector for reading CSV files into Kafka.
Stars: ✭ 116 (-1.69%)
Mutual labels:  json
Purescript Simple Json
A simple Purescript JSON library that uses types automatically
Stars: ✭ 117 (-0.85%)
Mutual labels:  json
Moyamapper
快速解析模型工具,支持RxSwift。同时支持缓存功能 【相关手册 https://MoyaMapper.github.io 】
Stars: ✭ 115 (-2.54%)
Mutual labels:  json
Fleece
A super-fast, compact, JSON-equivalent binary data format
Stars: ✭ 114 (-3.39%)
Mutual labels:  json
Groq
Specification for GROQ - Graph-Relational Object Queries
Stars: ✭ 117 (-0.85%)
Mutual labels:  json
Mockit
A tool to quickly mock out end points, setup delays and more...
Stars: ✭ 1,534 (+1200%)
Mutual labels:  json
Npoint
JSON storage bins with schema validation
Stars: ✭ 116 (-1.69%)
Mutual labels:  json
Symfony Jsonapi
JSON API Transformer Bundle for Symfony 2 and Symfony 3
Stars: ✭ 114 (-3.39%)
Mutual labels:  json
Administrative Divisions Of China
中华人民共和国行政区划:省级(省份直辖市自治区)、 地级(城市)、 县级(区县)、 乡级(乡镇街道)、 村级(村委会居委会) ,中国省市区镇村二级三级四级五级联动地址数据。
Stars: ✭ 11,727 (+9838.14%)
Mutual labels:  json
Config Lint
Command line tool to validate configuration files
Stars: ✭ 118 (+0%)
Mutual labels:  json
Hearthstone Db
A JSON collection of all Hearthstone cards. Hearthstone database.
Stars: ✭ 117 (-0.85%)
Mutual labels:  json
Easy Canvas
小程序简单绘图,通过 json 方式绘制一张朋友圈分享图
Stars: ✭ 117 (-0.85%)
Mutual labels:  json

jsonstore 🏪

GoDoc

JSONStore is a Go-library for a simple thread-safe in-memory JSON key-store with persistent backend. It's made for those times where you don't need a RDBMS like MySQL, or a NoSQL like MongoDB - basically when you just need a simple keystore. A really simple keystore. JSONStore is used in those times you don't need a distributed keystore like etcd, or a remote keystore Redis or a local keystore like Bolt. Its really for those times where you just need a JSON file.

Usage

First, install the library using:

go get -u -v github.com/schollz/jsonstore

Then you can add it to your program. Check out the examples, or see below for basic usage:

ks := new(jsonstore.JSONStore)

// set a key to any object you want
type Human struct {
  Name   string
  Height float64
}
err := ks.Set("human:1", Human{"Dante", 5.4})
if err != nil {
  panic(err)
}

// Saving will automatically gzip if .gz is provided
if err = jsonstore.Save(ks, "humans.json.gz"); err != nil {
  panic(err)
}

// Load any JSON / GZipped JSON
ks2, err := jsonstore.Open("humans.json.gz")
if err != nil {
  panic(err)
}

// get the data back via an interface
var human Human
err = ks2.Get("human:1", &human)
if err != nil {
  panic(err)
}
fmt.Println(human.Name) // Prints 'Dante'

The datastore on disk is then contains:

$ zcat humans.json.gz
{
"human:1": "{\"Name\":\"Dante\",\"Height\":5.4}"
}

JSONStore in the wild:

Dev

Benchmark against using Redis and BoltDB as KeyStores using Go1.8 (Intel i5-4310U CPU @ 2.00GHz). Take away is that setting/getting is faster in JSONStore (because its just a map), but opening is much slower (because its a file that is read into memory). So don't use this if you have to store 1,000,000+ things!

$ go test -bench=. tests/redis/* > redis.txt
$ go test -bench=. tests/bolt/* > bolt.txt
$ go test -bench=. > jsonstore.txt
$ benchcmp bolt.txt jsonstore.txt
benchmark                old ns/op     new ns/op     delta
BenchmarkSet-4           5471747       1847          -99.97%
BenchmarkGet-4           2424          1479          -38.99%
BenchmarkOpen100-4       11168         148035        +1225.53%
BenchmarkOpen10000-4     10095         19722376      +195267.77%
$ benchcmp redis.txt jsonstore.txt
benchmark                old ns/op     new ns/op     delta
BenchmarkSet-4           24717         1847          -92.53%
BenchmarkGet-4           22561         1479          -93.44%
BenchmarkOpen100-4       6221          148035        +2279.60%
BenchmarkOpen10000-4     4951          19722376      +398251.36%

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].