driver

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 2 Imported by: 4 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package driver defines interfaces to be implemented by cache backends as used by the github.com/bartventer/httpcache/store package.

Implementing a Cache Backend

To implement a custom cache backend, provide a type that implements the Conn interface.

The Driver interface is used to create a Conn from a URL.

The URL scheme determines which driver is used.

Implementations must be safe for concurrent use by multiple goroutines. Example implementations can be found in sub-packages such as store/memcache and store/fscache.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExist = errors.New("driver: entry does not exist")

ErrNotExist is returned when a cache entry does not exist.

Methods such as [Cache.Get] and [Cache.Delete] should return an error that satisfies errors.Is(err, store.ErrNotExist) if the entry is not found.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	// Get retrieves the cached value for the given key.
	// If the key does not exist, it should return an error satisfying
	// errors.Is(err, store.ErrNotExist).
	Get(key string) ([]byte, error)

	// Set stores the value for the given key.
	// If the key already exists, it should overwrite the existing value.
	Set(key string, value []byte) error

	// Delete removes the cached value for the given key.
	// If the key does not exist, it should return an error satisfying
	// errors.Is(err, store.ErrNotExist).
	Delete(key string) error
}

Conn describes the interface implemented by types that provide a connection to a cache backend. It allows for basic operations such as getting, setting, and deleting cache entries by key.

type Driver

type Driver interface {
	Open(u *url.URL) (Conn, error)
}

Driver is the interface implemented by cache backends that can create a Conn from a URL. The URL scheme determines which driver is used.

type DriverFunc

type DriverFunc func(u *url.URL) (Conn, error)

func (DriverFunc) Open

func (f DriverFunc) Open(u *url.URL) (Conn, error)

Jump to

Keyboard shortcuts

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