db

package
v0.0.0-...-73ed01f Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2021 License: MIT Imports: 2 Imported by: 0

README

db

The db package contains the implementation of the RavelDatabase struct and its functions. This is just a simple overlay on top of BadgerDB exposing common functions like Init, Close, Read , Write and Delete

  • Init - initialises the RavelDatabase struct and opens a connection to BadgerDB.
  • Close - closes the connection to BadgerDB.
  • Read - starts a read only transaction and returns the value for the given key.
  • Write - starts a read-write transaction, writes the key and value to badgerDB and then commits the transaction.
  • Delete - starts a read-write transaction, deletes the key value pair and commits the transaction.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RavelDatabase

type RavelDatabase struct {
	Conn *badger.DB
}

RavelDatabase represents an overlay on top of BadgerDB, it exposes Init, Close, Read, Write and Delete functions - these functions eventually perform mentioned operations on an instance of BadgerDB and these operations persist on disk

func (*RavelDatabase) Close

func (r *RavelDatabase) Close()

Close closes the connection to the BadgerDB instance

func (*RavelDatabase) Delete

func (r *RavelDatabase) Delete(key []byte) error

Delete deletes the key value pair with the corresponding key from BadgerDB

func (*RavelDatabase) Init

func (r *RavelDatabase) Init(path string) error

Init initialises BadgerDB with the path provided.

func (*RavelDatabase) Read

func (r *RavelDatabase) Read(key []byte) ([]byte, error)

Read returns the value with the corresponding key in the db

func (*RavelDatabase) ReadAndDelete

func (r *RavelDatabase) ReadAndDelete(key []byte) ([]byte, error)

func (*RavelDatabase) Write

func (r *RavelDatabase) Write(key []byte, val []byte) error

Write writes the key and value to BadgerDB

Jump to

Keyboard shortcuts

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