Coder Social home page Coder Social logo

minidb's Introduction

minidb

A storage engine similar to bitcask.

Getting Started

Installing

To start using minidb, install Go 1.19 or above. Minidb needs go modules. From your project, run the following command

$ go get github.com/yanghao888/minidb

This will retrieve the library.

Usage

// Open database
dir := filepath.Join(os.TempDir(), "minidb")
opts := minidb.DefaultOptions(dir)
db, err := minidb.Open(opts)
if err != nil {
    fmt.Printf("Error while opening minidb: %v\n", err)
    os.Exit(1)
}
defer db.Close()

// Put key-value
err = db.Put([]byte("name"), []byte("lion"))
if err != nil {
    fmt.Printf("Put value error: %v\n", err)
    return
}

// Get value
val, err := db.Get([]byte("name"))
if err != nil {
    fmt.Printf("Get value error: %v\n", err)
    return
}
fmt.Printf("Value is: %v\n", string(val))

// Delete key
err = db.Delete([]byte("name"))
if err != nil {
    fmt.Printf("Delete value error: %v\n", err)
    return
}

Design

Minidb’s design is based on a paper titled Bitcask: A Log-Structured Hash Table for Fast Key/Value Data.

Benchmarks

The benchmarking code, and the detailed logs for the benchmarks can be found in the benchmark package.

Run it by executing the following command in the root directory:

$ make bench

License

Minidb is licensed under the term of the GPLv2 License.

minidb's People

Contributors

yanghao888 avatar

Watchers

 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.