Ystore

A flexible data/config file parser
Alternatives To Ystore
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Etcd42,9324,0482,314a day ago396April 24, 2022235apache-2.0Go
Distributed reliable key-value store for the most critical data of a distributed system
Arangodb12,853
21 hours ago240May 23, 2018772apache-2.0C++
🥑 ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values. Build high performance applications using a convenient SQL-like query language or JavaScript extensions.
Badger12,0267543 days ago48August 25, 202121apache-2.0Go
Fast key-value DB in Go.
Zookeeper11,149
6 days ago1December 18, 2019222apache-2.0Java
Apache ZooKeeper
Bolt10,6624,0571,0845 years ago8July 17, 201784mitGo
An embedded key/value database for Go.
Immudb8,121152 days ago130August 25, 2022143apache-2.0Go
immudb - immutable database based on zero trust, SQL and Key-Value, tamperproof, data change history
Buntdb3,838732297 months ago28August 19, 202214mitGo
BuntDB is an embeddable, in-memory key/value database for Go with custom indexing and geospatial support
Rosedb3,581
2 months ago54June 16, 202213apache-2.0Go
🚀 A high performance NoSQL database based on bitcask, supports string, list, hash, set, and sorted set.
Hive3,455217510 days ago52June 30, 2022457apache-2.0Dart
Lightweight and blazing fast key-value database written in pure Dart.
Immortaldb3,011323 months ago4August 20, 202038mitJavaScript
:nut_and_bolt: A relentless key-value store for the browser.
Alternatives To Ystore
Select To Compare


Alternative Project Comparisons
Readme


ystore is a data management tool. It can be used as a generic key-value datastore, for flexible configuration storage or used as a way to import arbitrary data into your application from data files (e.g.: from a CMS or other system).

The goal of ystore's is to provide flexible access to your data.

Features

  • flexible key-value storage
  • load directly from JSON, TOML and YAML files
  • merge whole directories of files into single stores
  • simple nested key queries (e.g.: GetString("node.sub.key"))
  • match store keys using a pattern
  • Store splitting and merging
  • conversion from map values

Memory-based Stores

At it's core, ystore is a simple key-value store. You can easily create a simple Store like so:

store := NewStore()
store.Set("color", "red")
store.Set("length", 100)
fmt.Printf("The item is %s and the length is %d.\n", 
	store.GetString("color"), store.GetInt("length"))
// Output: The item is red and the length is 100.

You can also implement your store with default values using a the map initializer:

store := NewStoreFromMap(map[string]interface{}{
	"color" : green,
	"length" : 80,
})
fmt.Printf("The item is %s and the length is %d.\n", 
	store.GetString("color"), store.GetInt("length"))
// Output: The item is green and the length is 80.

File-based Stores

Let's assume we have a .toml file that looks like this:

[item]
name="First Item"
colors=["red", "green", "blue"]
numbers=[5, 2, 1, 6, 5]

We can load the file by creating a Store and then using the ReadFile function. Note: You will need to pass the absolute file path to ReadFile.

filename, fileErr := filepath.Abs("./config.toml")
if fileErr != nil {
	// handle the path error
	return
}
store := NewStore()
if readErr := store.ReadFile(filename); readErr != nil {
	// handle store load error
	return
}
name := store.GetString("item.name")
numbers := store.GetIntSlice("item.numbers")
fmt.Printf("The item name is '%s' and the numbers slice has %d element(s).\n", name, len(numbers))
// Output: The item name is 'First Item' and the numbers slice has 5 element(s).

FAQ

Can I use this as a database?

You could, but it may not be the best solution. Our goal is to provide a super flexible data management solution for a variety of application data and to not be a full scale database. A quick search on Google will find a variety of great solutions if you need to embed a database.

How is this different to Viper?

First up, Viper is fantastic and super useful. ystore isn't trying to compete with viper.

The overall intent of ystore is to offer a more generic data mechanism, to allow files/formats to be used interchangeably, and to make it simple to just parse a bunch of it at the same time. Viper is more suited for application configuration specific task. You can still use ystore for application configuration (it works great!) but you may end up needing to do a few additional tasks yourself.

Related

Viper - Go configuration with fangs

License

ystore is released under a modified MIT license. See LICENSE for details.

Portions of the code are derived from other works. Please see NOTICE for details on usage and their associated licenses.

Popular Database Projects
Popular Key Value Projects
Popular Data Storage Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Go
Database
Key Value
Configuration Management
Viper