GithubHelp home page GithubHelp logo

gosnipp / go-store Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gosuri/go-store

0.0 2.0 0.0 91 KB

A simple and fast Redis backed key-value store library for Go

License: Apache License 2.0

Makefile 0.45% Go 99.55%

go-store's Introduction

store GoDoc Build Status

store is a data-store library for Go that provides a set of platform-independent interfaces to persist and retrieve data.

Its primary goal is to wrap existing implementations of such primitives, such as those in package redis, into shared public interfaces that abstract functionality, plus some other related primitives.

It currently supports Redis from the redis package.

NOTE: This library is currently under active development and not ready for production use.

Example

The below example stores, lists and fetches the saved records

package main

import (
  "fmt"

  "github.com/gosuri/go-store/redis"
)

type hacker struct {
  Id        string
  Name      string
  Birthyear int
}

func (h *hacker) Key() string {
  return h.Id
}

func (h *hacker) SetKey(k string) {
  h.Id = k
}

func main() {
  store, err := redis.NewStore("", "")
  if err != nil {
    panic(err) // handle error
  }

  // Save a hacker in the store with a auto-generated uuid
  if err := store.Write(&hacker{Name: "Alan Turing", Birthyear: 1912}); err != nil {
    panic(err) // handle error
  }

  var hackers []hacker
  // Populate hackers slice with ids of all hackers in the store
  store.List(&hackers)

  alan := hackers[0]
  store.Read(&alan)
  fmt.Println("Hello,", alan.Name)

  fmt.Println("Listing all", len(hackers), "hackers")
  // Fetches all hackers with names from the store
  store.ReadMultiple(hackers)
  for _, h := range hackers {
    fmt.Printf("%s (%d) (%s)\n", h.Name, h.Birthyear, h.Id)
  }
}

Roadmap

Below are items I am and plan on working on in the near future. Contributions are welcome.

Feature Status
Save multiple records in a single call using pipelining implementing
Query (using finders) and indexing

Contributing

Dependency management

Users who import store into their package main are responsible to organize and maintain all of their dependencies to ensure code compatibility and build reproducibility. Store makes no direct use of dependency management tools like Godep.

We will use a variety of continuous integration providers to find and fix compatibility problems as soon as they occur.

Running Testing

$ make test

Benchmarks

$ make benchmark
...
BenchmarkRedisWrite      10000  104302 ns/op
BenchmarkRead            20000  65870 ns/op
BenchmarkRead1k          20     67325041 ns/op
BenchmarkRedisList1k     50     27598338 ns/op
BenchmarkRedisList10k    30     71845057 ns/op
BenchmarkReadMultiple1k  200    7453783 ns/op

go-store's People

Contributors

sofuture avatar

Watchers

James Cloos avatar QUASI 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.