Skip to content

salamer/Juicy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Juicy 🍸

"It was all a dream, I used to read Word Up! magazine."

-- The Notorious B.I.G.

Juicy is a simple memory key/value database. it use naive_raft to support distributed consistency. It is not finished yet, only partial functions are supported.

INSTALL

go get -u github.com/salamer/Juicy

QUICK START

Client Side

package main

import (
	"fmt"

	client "github.com/salamer/Juicy/client"
)

func main() {
	c := client.NewJuicyClient("localhost", 8080)
	c.Set("helloq", "world")
	c.Set("hahah", "wwww")
	c.Set("aaaa", "zzzz")
	fmt.Println(c.Get("aaaa"))
	fmt.Println(c.Get("helloq"))
	fmt.Println(c.Get("hahah"))
	fmt.Println(c.Delete("hahah"))
	fmt.Println(c.Get("hahah"))
	c.Persist("aaa.txt")
	fmt.Println(c.Empty())
	c.Persist("db.juicy")
	c.Clear()
	fmt.Println(c.Empty())
}

Server Side

Single Node

package main

import (
	"fmt"

	Juicy "github.com/salamer/Juicy"
)

func main() {
	db := Juicy.NewDB("hello", Juicy.SINGLE, Juicy.RaftConf{})
	db.Start()
}

Multi Node

package main

import (
	"fmt"

	Juicy "github.com/salamer/Juicy"
)

const ConfPath = {confpath}      //your node conf json file
const ID = {id}                  //your node id
const Name = {name}              //your node name
const Host = {host}              //your raft node host
const Port = {port}              //your raft node port

func main() {
	db := Juicy.NewDB("hello", Juicy.DISTRIBUTED, Juicy.RaftConf{
		ID:       ID,
		Name:     Name,
		ConfPath: ConfPath,
		Port:     Port,
		Host:     Host,
	})
	db.Start()
}

TODO

  • Compress
  • Better Persist

LICENSE

Copyright © 2018 by Aljun

Under Apache license : http://www.apache.org/licenses/