afiflampard / MemoryStore

Go - MemoryStore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

๐Ÿš€ MemoryStore: The Speedy In-Memory ๐Ÿ—‚ Key-Value Store ๐Ÿ› ๏ธ

MemoryStore is an ultra-fast, in-memory key-value database developed in Go, emphasizing rapid data access, simple integration, and robust thread-safe operations. It excels in handling byte-slice data with flexible serialization options.

Quick Start

Clone and navigate to the MemoryStore repository:

git clone https://github.com/BryceWayne/MemoryStore.git
cd MemoryStore

How to Use

MemoryStore accepts []byte as values, accommodating various serialization methods (JSON, gob, protobuf, etc.). Here's a quick guide to integrate MemoryStore into your Go application:

import (
    "github.com/goccy/go-json" // Recommended for added performance in JSON serialization
    "log"
    "time"

    "github.com/BryceWayne/MemoryStore/memorystore"
)

type YourData struct {
    // Define your data structure here
}

func main() {
    ms := memorystore.NewMemoryStore()
    defer ms.Stop()

    // Convert your data to a byte slice
    dataToStore := YourData{/* ... */}
    serializedData, err := json.Marshal(dataToStore)
    if err != nil {
        log.Fatal(err)
    }

    // Store the data
    ms.Set("yourKey", serializedData, 10*time.Second)

    // Retrieve and use the data
    if data, found := ms.Get("yourKey"); found {
        var yourData YourData
        if err := json.Unmarshal(data, &yourData); err != nil {
            log.Fatal(err)
        }
        // Process `yourData`...
    }

    // Remove the data
    ms.Delete("yourKey")
}

Building and Testing

Build the project with the Makefile:

make build

This compiles the source into an executable.

Test the functionality:

make test

Contributions

Your contributions make MemoryStore better. Feel free to submit pull requests, open issues for discussion, suggestions, or bug reports.

About

Go - MemoryStore

License:MIT License


Languages

Language:Go 96.0%Language:Makefile 4.0%