Git Product home page Git Product logo

imdgo's Introduction

IMDGO - In-Memory Data Grid in Go

Or simply - a light-weight distributed in-memory key-value store inspired primarily by Hazelcast.

IMDGO is built on top of Raft consensus protocol (Hashicorp's implementation) where all write (set and delete) operations are done through Raft and reads are done from a local replica. This means that it is possible for a read operation to see a stale value in some cases (e.g. a value is updated on the leader while the same value is read from some follower node that didn't get the updated value). This, on the other hand, makes read operation really fast.

imdgo diagram

Because of the leader based replication with Raft, every write and delete operation go to the leader (in case request hits a follower node) and then are replicated to followers. Currently, these requests are forwarded via plain old HTTP with JSON, but it will be done with MessagePack or gRPC.

It uses orcaman/concurrent-map as an underlining map to reduce locking and contention as much as possible.

Upcoming features:

  • Stronger consistency model and ability to configure it
  • data partitioning (currently every node holds all the data)
  • multiple distinct maps
  • item TTL and eviction
  • memory usage management (set the percentage of the app's memory for imdgo)
  • store management API

Beside the new stuff, there are non-functional things to improve and for sure bugs to fix.

Quickstart

Import the package:

import (
    "github.com/inelpandzic/imdgo"
)
go get "github.com/inelpandzic/imdgo"

Usage

// set the members of your application cluster
c := &imdgo.Config{Members: []string{"192.168.10.1", "192.168.10.2", "192.168.10.3"}}
store, err := imdgo.New(c)
if err != nil {
    panic(err)
}
defer store.Close()

key := "my-key"

// You can set the value on one node or application instance
err := store.Set(key, "and my value which can be anything, not just string")
if err != nil {
    log.Error(err))
}

// And then you can get it on some other application instance, safely replicated
if val, ok := m.Get(key); ok {
    fmt.Println(val)
}

For now, imdgo runs with only default preconfigured ports 6701 and 6801 which needs to be available.

Credits

Credit goes to otoolep and his hraft for helping me get started quickly with Hashicorp's Raft lib. There is code from hraft in imdgo, I don't change something that is good for the time being.

imdgo's People

Contributors

inelpandzic avatar

Watchers

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