Code Monkey home page Code Monkey logo

snapshot's Introduction

Snapshot

Build Status Project status Go Report Card GoDoc License

Robust, Persistent, Key-Value (KV) store purely written in Golang

Installation

$ go get github.com/thedevsaddam/snapshot

Usage

package main

import (
	"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.

snapshot's People

Contributors

thedevsaddam avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.