boltdbcache

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 1 Imported by: 1

README

boltdbcache

Package boltdbcache provides a file system based cache backend for Greg Jones' httpcache using coreos/bbolt.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is an implementation of httpcache.Cache that uses a bolt database.

func New

func New(path string, opts ...Option) (*Cache, error)

New returns a new Cache that uses a bolt database at the given path.

func NewWithDB

func NewWithDB(db *bolt.DB, opts ...Option) (*Cache, error)

NewWithDB returns a new Cache using the provided (and opened) bolt database.

func (*Cache) Close

func (c *Cache) Close() error

Close closes the underlying boltdb database.

func (*Cache) Delete

func (c *Cache) Delete(key string)

Delete removes the response with the given key from the cache.

func (*Cache) Get

func (c *Cache) Get(key string) (resp []byte, ok bool)

Get retrieves the response corresponding to the given key if present.

func (*Cache) Set

func (c *Cache) Set(key string, resp []byte)

Set stores a response to the cache at the given key.

type Option

type Option func(*Cache)

An Option is a function that applies an option to a Cache.

func WithBucketName

func WithBucketName(name string) Option

WithBucketName is a functional option that sets the bucket name to use for this cache.

Jump to

Keyboard shortcuts

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