Git Product home page Git Product logo

gobdb's Introduction

Go ReferenceLicense: MITGo Report Card

gobdb

gobdb is a simple key-value database for Go binary objects encoded with encoding/gob.

Features

  • Open: Opens a file at the specified path and decodes its contents using the gob decoder.
  • List: Returns the entire database as an array.
  • Add: Appends a new value to the database and persist data to disk.

Usage

Open a Database

db, err := gobdb.Open[YourType]("path/to/yourfile.gob")
if err != nil {
    // handle error
}

List the Database Contents

data := db.List()
for _, item := range data {
    // process item
}

Add Data to the Database

err := db.Add(yourData)
if err != nil {
    // handle error
}

Use Cases

This package is ideal for simple use-cases where you need to persist and retrieve Go binary objects without the overhead of a full-fledged database system. Here are a few scenarios where it can be handy:

  • Caching: You can use gobdb to cache complex data structures that take time to generate or fetch from a slow source. This way, you can quickly retrieve the data from the disk whenever needed.

  • Local Data Persistence: If you're building a Go application that needs to store data locally, you can use gobdb as a lightweight, file-based database.

  • Data Serialization: The package can also be used for serializing and deserializing Go data structures for network communication or other purposes where you need to convert Go objects to a binary format and vice versa.

TODO

While gobdb provides a convenient way to work with gob encoded data, there are several features that could improve its utility:

  • Delete Functionality: Currently, there's no way to delete data from the database. This feature is crucial for managing the data efficiently.

  • Update Functionality: Another missing feature is the ability to update an existing value in the database.

  • Search Functionality: The package currently lacks a way to search for a specific data object in the database. Implementing this would provide quicker access to data.

  • Concurrency Safety: The package isn't currently safe for concurrent use. It would be beneficial to add some form of locking to ensure that concurrent reads and writes don't cause data corruption.

  • Error Handling: The current error handling could be improved, for instance by providing more detailed error messages or different types of errors for different failure cases.

  • Batch Operations: Adding support for batch operations could improve performance when working with large amounts of data.

Contributions are welcome to help implement these features and improve this package.

gobdb's People

Contributors

thiagonache avatar waltervargas 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.