bolt

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 5 Imported by: 2

README

Cachego - BoltDB driver

The drivers uses etcd-io/bbolt to store the cache data.

Usage

package main

import (
	"log"
	"time"

	bt "go.etcd.io/bbolt"

	"github.com/faabiosr/cachego/bolt"
)

func main() {
	db, err := bt.Open("cache.db", 0600, nil)
	if err != nil {
		log.Fatal(err)
	}

	cache := bolt.New(db)

	if err := cache.Save("user_id", "1", 10*time.Second); err != nil {
		log.Fatal(err)
	}

	id, err := cache.Fetch("user_id")
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("user id: %s \n", id)
}

Documentation

Overview

Package bolt providers a cache driver that stores the cache using BoltDB.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(db *bt.DB) cachego.Cache

New creates an instance of BoltDB cache

Types

This section is empty.

Jump to

Keyboard shortcuts

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