imagecache

package
v0.0.0-...-3f13264 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrContentType = errors.New("cache: Content-Type of image is not recognized")

Functions

This section is empty.

Types

type Cache

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

func New

func New(opts ...Option) *Cache

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, url string) (*bytes.Buffer, error)

Get returns a buffered image from the cache. The image will be downloaded if it doesn't already exist within.

func (*Cache) Start

func (c *Cache) Start()

Start enables the automatic deletion of expired items. This method is blocking.

func (*Cache) Stop

func (c *Cache) Stop()

Stop disables the automatic deletion of expired items. This method is blocking.

type Option

type Option func(*Cache)

Option configures a Cache.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient specifies the HTTP Client to use for image downloading.

func WithTTL

func WithTTL(dur time.Duration) Option

WithTTL sets the TTL on the cache.

Jump to

Keyboard shortcuts

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