ebolt

package module
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 5 Imported by: 0

README

Ebolt

Go Report Card GoDoc

Ebolt is a lightweight Go package designed as a versatile wrapper for the bbolt key-value store. It offers a simplified interface with generic PUT, GET, and DELETE methods, along with the added convenience of expiration for key-value pairs.

Installation

To use ebolt in your Go project, you can install it using the following go get command:

go get github.com/kimbbakar/ebolt

Usage

Here's a quick example of how to use ebolt in your Go code:

package main

import (
	"time"

	ebolt "github.com/kimbbakar/ebolt"
)

func main() {

	// Init ebolt befor every restart to sweep expired key.
	// Passing bucket name will create bucket
	ebolt.InitEbolt(nil)

	// key-value without any expiry
	ebolt.DB.Put("my-key", "my-value", nil)

	// key-value with any expiry
	exp := time.Minute * 10
	ebolt.DB.Put("my-key", "my-value", &exp)

	// Delete key
	ebolt.DB.Delete("my-key")

	// Get Key
	ebolt.DB.Get("my-key")
}

Features

  • Generic PUT, GET, DELETE operations
  • Expiration for key-value pairs

Contributing

Contributions are welcome! If you have ideas for improvements or find any issues, feel free to open an issue or submit a pull request.

License

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB = &EBoltClient{}

Functions

func InitEbolt

func InitEbolt(bucketName *string)

Types

type EBoltClient

type EBoltClient struct {
	// contains filtered or unexported fields
}

func GetEbolt

func GetEbolt(Name string) *EBoltClient

func (*EBoltClient) Delete

func (c *EBoltClient) Delete(key string) error

func (*EBoltClient) DeleteMany

func (c *EBoltClient) DeleteMany(keys []string) error

func (*EBoltClient) Get

func (c *EBoltClient) Get(key string) interface{}

func (*EBoltClient) Init

func (c *EBoltClient) Init()

func (*EBoltClient) Put

func (c *EBoltClient) Put(key string, value interface{}, ttl *time.Duration) error

func (*EBoltClient) Sweep

func (c *EBoltClient) Sweep()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL