Skip to content

Latest commit

 

History

History
91 lines (63 loc) · 2.68 KB

README.md

File metadata and controls

91 lines (63 loc) · 2.68 KB

go-memdb

A very simple in-memory key-value database implemented in Go for investigative purposes. Supports basic CRUD operations and nested transactions.

All CRUD operations occur at O(1) time complexity, as a hash map is utilised. A separate hash map (index) is created for the values stored, such that we can count the number of occurrences of a given value at O(1) time complexity as well.

⚠️ WARNING: Not for production use!

Documentation

The full documentation is available on GoDoc.

Getting Started

These instructions will inform you on how to run this project on a local/development machine for investigative purposes. Please do not use this in production. There is no error handling or tests implemented yet.

Prerequisites

  • A working Go installation (v1.14 or above, preferred)

An example CLI that integrate's this project's memdb APIs can be downloaded from the releases page.

Installing/Importing

Fetch this package using:

go get github.com/rquitales/go-memdb/memdb

Using This Package

Use within your own projects by importing memdb:

import (
    "github.com/rquitales/go-memdb/memdb
)

Create a new database instance with:

db := memdb.NewDB()

Please refer to the GoDoc page full documentation. A example CLI implementation of memdb can also be seen in the main.go file.

Running The Example CLI

From Source

  1. Download the appropriate binary from your target OS from the releases page, or compile from source with go build -v . after cloning this repository.
  2. Start the executable, eg: ./go-memdb
  3. Type your commands (into STDIN)

Supported statements are:

  • SET [key] [value]
  • GET [key]
  • DELETE [key]
  • COUNT [value]
  • END
  • BEGIN
  • ROLLBACK
  • COMMIT

The query/functions are case insensitive, but the key/values are case sensitive!

With Docker

  1. Build the docker image from the given Dockerfile in this project:
    docker build -t go-memdb .
    
  2. Run the built image in a container interactively:
    docker run -it --rm go-memdb
    

Built With

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details