Monday, July 22, 2024
HomeGolangA easy, quick, embeddable, persistent key/worth retailer written in pure Golang

A easy, quick, embeddable, persistent key/worth retailer written in pure Golang


NutsDB is an easy, quick, embeddable, persistent key/worth retailer written in pure Golang.

It helps totally serializable transactions, and lots of information constructions akin to checklist、set、sorted set. All operations occur inside a Tx. Tx represents a transaction, which could be read-only or read-write. Learn-only transactions can learn values for a given bucket and a given key or iterate over a set of key-value pairs. Learn-write transactions can learn, replace and delete keys from the DB.

Getting Began with NutsDB

Putting in

To begin utilizing NutsDB, first wants Go put in (model 1.11+ is required). and run go get:

go get -u github.com/xujiajun/nutsdb

Opening a database

To open your database, use the nutsdb.Open() perform,with the suitable choices.The Dir , EntryIdxMode and SegmentSize choices are should be specified by the consumer. About choices see right here for element.

bundle essential

import (
    "log"

    "github.com/xujiajun/nutsdb"
)

func essential() {
    // Open the database situated within the /tmp/nutsdb listing.
    // It is going to be created if it would not exist.
    db, err := nutsdb.Open(
        nutsdb.DefaultOptions,
        nutsdb.WithDir("/tmp/nutsdb"),
    )
    if err != nil {
        log.Deadly(err)
    }
    defer db.Shut()

    ...
}

Choices

Dir represents Open the database situated during which dir.

  • EntryIdxMode EntryIdxMode

EntryIdxMode represents utilizing which mode to index the entries. EntryIdxMode contains three choices: HintKeyValAndRAMIdxMode,HintKeyAndRAMIdxMode and HintBPTSparseIdxModeHintKeyValAndRAMIdxMode represents ram index (key and worth) mode, HintKeyAndRAMIdxMode represents ram index (solely key) mode and HintBPTSparseIdxMode represents b+ tree sparse index mode.

RWMode represents the learn and write mode. RWMode contains two choices: FileIO and MMap. FileIO represents the learn and write mode utilizing customary I/O. And MMap represents the learn and write mode utilizing mmap.

NutsDB will truncate information file if the lively file is bigger than SegmentSize. Present model default SegmentSize is 8MB,however you may customized it. The defaultSegmentSize turns into 256MB when the model is bigger than 0.8.0.

As soon as set, it can’t be modified. see caveats–limitations for element.

NodeNum represents the node quantity.Default NodeNum is 1. NodeNum vary [1,1023] .

SyncEnable represents if name Sync() perform. if SyncEnable is fake, excessive write efficiency however potential information loss doubtless. if SyncEnable is true, slower however persistent.

  • StartFileLoadingMode RWMode

StartFileLoadingMode represents when opening a database during which RWMode masses information.

This Golang Bundle is impressed by the next:

License

The NutsDB is open-sourced software program licensed below the Apache 2.0 license.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments