cache

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheMiddleware

func CacheMiddleware(cache Cache) func(http.Handler) http.Handler

Types

type Cache

type Cache interface {
	Set(key string, value CachedResponse, duration time.Duration) error
	Get(key string) (CachedResponse, bool)
	Delete(key string) error
	Clear() error
}

type CachedResponse

type CachedResponse struct {
	ContentType string
	Data        []byte
}

type FileCache

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

func NewFileCache

func NewFileCache(baseDir string) *FileCache

func (*FileCache) Clear

func (f *FileCache) Clear() error

func (*FileCache) Delete

func (f *FileCache) Delete(key string) error

func (*FileCache) Get

func (f *FileCache) Get(key string) (CachedResponse, bool)

func (*FileCache) Set

func (f *FileCache) Set(key string, value CachedResponse, duration time.Duration) error

type MemoryCache

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

func NewMemoryCache

func NewMemoryCache() *MemoryCache

func (*MemoryCache) Clear

func (m *MemoryCache) Clear() error

func (*MemoryCache) Delete

func (m *MemoryCache) Delete(key string) error

func (*MemoryCache) Get

func (m *MemoryCache) Get(key string) (CachedResponse, bool)

func (*MemoryCache) Set

func (m *MemoryCache) Set(key string, value CachedResponse, duration time.Duration) error

Jump to

Keyboard shortcuts

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