letterbeezps / pickledb

PickleDB-go is a lightweight and simple key-value store. It is a Golang version for Python's PickleDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PickleDB-go

A lightweight and simple key-value store written in Go, inspired by Python's PickleDB and PickleDB-rs.

When I used go to refactor the python project of my former colleague, I tried to find an alternative to pickleDB in go.dev, but it failed. Fortunately, the source code of pickleDB is not complicated, so I try to develop a pickleDB-go by myself.

The core of the project is to user map[string]interface{} represent arbitray data.

exmaple

package main

import (
    "fmt"

    "github.com/letterbeezps/pickledb"
)

func main() {
    Dump()

    Load()
}

func Dump() {
    db := pickledb.Load("test.db", false)

    db.Set("letter", "letter_value")
    db.Dump()
}

func Load() {
    db := pickledb.Load("test.db", false)

    v, _ := db.Get("letter")
    fmt.Println(v)
}
go run main.go

Create test.db in the current folder

About

PickleDB-go is a lightweight and simple key-value store. It is a Golang version for Python's PickleDB


Languages

Language:Go 100.0%