example

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type CacheService

type CacheService[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewCacheService

func NewCacheService[K comparable, V any](ctx context.Context, cfg Config, db DB[K, V]) *CacheService[K, V]

func (*CacheService[K, V]) Get

func (srv *CacheService[K, V]) Get(k K) (v V, err error)

func (*CacheService[K, V]) Set

func (srv *CacheService[K, V]) Set(k K, v V) error

type Config

type Config struct {
	TTL      time.Duration
	Capacity int
}

type DB

type DB[K comparable, V any] interface {
	Set(k K, v V) error
	Get(k K) (v V, ok error)
}

Jump to

Keyboard shortcuts

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