streamlet

package module
v0.0.0-...-e65d08d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2020 License: MIT Imports: 4 Imported by: 0

README

Streamlet

Streamlet is originally a NodeJS-based stream-oriented database optimal for small scale projects that need a high speed method for storing data. This version of streamlet has been rewritten in Go for maximum speed and portability.

This version of Streamlet used to use os.Write, but after extensive testing, it was determined that it was about 2000x faster to use bufio. Before the change to bufio, the database clocked in at ~3500 ns/op for bulk inserts. It now takes ~1600 ns/op.

On average, Streamlet can achieve 450,000 ops/sec write speed on a Dell XPS 13. Streamlet can achieve 1000ns/doc read speed on the same device.

Installation


GO111MODULE=on
go get github.com/SuperAuguste/streamlet

License

This project is licensed under the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Streamlet

type Streamlet struct {
	ReadWriter io.ReadWriter
	Writer     *bufio.Writer
	FSI        fsi.FSI
	Documents  map[string]StreamletDocument
}

func New

func New(readWriter io.ReadWriter) Streamlet

Create / open a new Streamlet instance.

func (*Streamlet) Delete

func (db *Streamlet) Delete(id string)

Deletes a document from the database.

func (*Streamlet) DeleteBulk

func (db *Streamlet) DeleteBulk(ids []string)

Deletes more than one line of documents from the database.

func (*Streamlet) Edit

func (db *Streamlet) Edit(id string, document map[string]interface{})

Edits a document.

func (*Streamlet) Find

func (db *Streamlet) Find(callback func(document StreamletDocument) bool) []StreamletDocument

Finds multiple documents that return true as a result of the callback function.

func (*Streamlet) FindOne

func (db *Streamlet) FindOne(callback func(document StreamletDocument) bool) StreamletDocument

Finds one document that return true as a result of the callback function.

func (*Streamlet) Get

func (db *Streamlet) Get(id string) StreamletDocument

Gets one document by id.

func (*Streamlet) Init

func (db *Streamlet) Init()

Reads the contents of the database.

func (*Streamlet) Insert

func (db *Streamlet) Insert(document map[string]interface{})

Inserts a document into the database.

func (*Streamlet) InsertBulk

func (db *Streamlet) InsertBulk(documents []map[string]interface{})

Inserts more than one line of documents into the database.

func (*Streamlet) Keys

func (db *Streamlet) Keys() []string

func (*Streamlet) Update

func (db *Streamlet) Update(document StreamletDocument)

type StreamletDocument

type StreamletDocument struct {
	Id   string
	Data map[string]interface{}
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL