Coder Social home page Coder Social logo

kashk's Introduction

Kashk Storage

Overview

Kashk Storage contains a versatile and configurable key-value storage engine written in Go. The engine offers efficient key-value storage, retrieval, and deletion operations, optimized for concurrency and featuring automatic size-based data file rotation.

Features

  • Put Key-Value Pairs: Efficiently put key-value pairs into the storage file, almost similar to the performance of writing to a file.
  • In-Memory Indexing: Utilizes an in-memory index for quick data retrieval.
  • Thread-Safe: It provides safe concurrent read and write access via a read-write mutex.
  • Read Values by Key: Retrieve values quickly using an in-memory index.
  • Delete Key-Value Pairs: Efficiently delete key-value pairs by marking them with a tombstone value.
  • Customizable File Size: Set the maximum size for each log file. A new file will be used when the current one exceeds this limit.
  • Customizable Key Size: Control the maximum allowed size for keys.
  • Customizable File Names: You can set the name for the data file.
  • Customizable Tombstone Value: You can define the tombstone value for marking deleted entries.

Getting Started

Installation

  1. Clone this repository or download the source code.
  2. Create a data and give the user permission to read and write to it.

Usage

Here's how to create a new storage engine and use its features:

import "path-to-storage-package/storage"

// Initialize a new storage engine with default settings
engine, err := storage.NewEngine("./data-path/")
if err != nil {
    log.Fatal("Failed to initialize engine:", err)
}

// Initialize with options
engine, err := storage.NewEngine("./data-path/",
    storage.WithMaxLogSize(10 * storage.MB),
    storage.WithMaxKeySize(1 * storage.KB),
    storage.WithTombStone("custom_tombstone")
)
if err != nil {
    log.Fatal("Failed to initialize engine with options:", err)
}

// Put a key-value pair
err = engine.Put("name", "John Doe")
if err != nil {
    log.Fatal("Failed to append key-value pair:", err)
}

// Read a value back
value, err := engine.Get("name")
if err != nil {
    log.Fatal("Failed to get value:", err)
}

// Delete a key-value pair
err = engine.Delete("name")
if err != nil {
    log.Fatal("Failed to delete key-value pair:", err)
}

kashk's People

Contributors

rezkam avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

kashk's Issues

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.