https://github.com/thedevsaddam/snapshot
Robust, Persistent, Key-Value (KV) store purely written in Golang
https://github.com/thedevsaddam/snapshot
go-key-value golang-key-value key-value-database key-value-store kv
Last synced: 7 months ago
JSON representation
Robust, Persistent, Key-Value (KV) store purely written in Golang
- Host: GitHub
- URL: https://github.com/thedevsaddam/snapshot
- Owner: thedevsaddam
- License: mit
- Created: 2017-07-27T17:59:46.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-25T01:43:06.000Z (about 6 years ago)
- Last Synced: 2024-06-20T17:33:49.841Z (over 1 year ago)
- Topics: go-key-value, golang-key-value, key-value-database, key-value-store, kv
- Language: Go
- Homepage: https://godoc.org/github.com/thedevsaddam/snapshot
- Size: 7.81 KB
- Stars: 11
- Watchers: 4
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Snapshot
[](https://travis-ci.org/thedevsaddam/snapshot)

[](https://goreportcard.com/report/github.com/thedevsaddam/snapshot)
[](https://godoc.org/github.com/thedevsaddam/snapshot)
Robust, Persistent, Key-Value (KV) store purely written in Golang
### Installation
```bash
$ go get github.com/thedevsaddam/snapshot
```### Usage
```go
package mainimport (
"fmt"
"github.com/thedevsaddam/snapshot"
"time"
)//make a type to use
type User struct {
Name, Occupation string
CreatedAt time.Time
}func main() {
//create a snapshot collection
userCollection, err := snapshot.New("users")
if err != nil {
fmt.Println(err)
}//add item to collection
userCollection.Put("john", User{Name: "John Doe", Occupation: "Software Engineer", CreatedAt: time.Now()})
userCollection.Put("jane", User{Name: "Jane Doe", Occupation: "UI/UX Designer", CreatedAt: time.Now()})//get an item from collection
john := User{}
userCollection.Get("john", &john)
fmt.Printf("%s is a %s\n", john.Name, john.Occupation) //John Doe is a Software Engineer//check an item is exist in a collection
fmt.Println(userCollection.Has("john")) //true
fmt.Println(userCollection.Has("tom")) //false//get all the item keys list
fmt.Println(userCollection.List())//get total item count
fmt.Println(userCollection.TotalItem())//remove a key from collection
userCollection.Remove("john")//remove all the keys with collection
userCollection.Flush()}
```
### License
The **snapshot** is a open-source software licensed under the [MIT License](LICENSE.md).