imagecache

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 15 Imported by: 0

README

imagecache

Documentation

Overview

this the double linked list from https://pkg.go.dev/container/list the only change is, that it uses generics for the value

Index

Constants

View Source
const (
	KB = 1024
	MB = KB * 1024
	GB = MB * 1024
)

Variables

This section is empty.

Functions

func GetSupportedTypes

func GetSupportedTypes() []bimg.ImageType

func SupportsType

func SupportsType(t bimg.ImageType) bool

Types

type Cache

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

func New

func New(store Storer, layers ...*Layer) *Cache

func (*Cache) Clear

func (c *Cache) Clear(name string)

func (*Cache) Handle

func (c *Cache) Handle(imageType bimg.ImageType, config bimg.Options) (Handler, error)

type Cacher

type Cacher interface {
	Put(name string, content []byte) error
	Exists(name string) bool
	Delete(name string) error
	Get(name string) ([]byte, error)
}

type Element

type Element[T any] struct {

	// The value stored with this element.
	Value T
	// contains filtered or unexported fields
}

Element is an element of a linked list.

func (*Element[T]) Next

func (e *Element[T]) Next() *Element[T]

Next returns the next list element or nil.

func (*Element[T]) Prev

func (e *Element[T]) Prev() *Element[T]

Prev returns the previous list element or nil.

type EvictionStrategy

type EvictionStrategy interface {
	// contains filtered or unexported methods
}

type FileSystem

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

func NewFileSystem

func NewFileSystem(path string) (*FileSystem, error)

func (*FileSystem) Delete

func (fs *FileSystem) Delete(name string) error

func (*FileSystem) Exists

func (fs *FileSystem) Exists(name string) bool

func (*FileSystem) Get

func (fs *FileSystem) Get(name string) ([]byte, error)

func (*FileSystem) Put

func (fs *FileSystem) Put(name string, data []byte) error

type Handler

type Handler func(string, http.ResponseWriter)

type Item

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

type LastAccessEviction

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

func NewLastAccessEviction

func NewLastAccessEviction(duration time.Duration) *LastAccessEviction

type Layer

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

func NewLayer

func NewLayer(cache Cacher, evictions ...EvictionStrategy) *Layer

func (*Layer) BackgroundEviction

func (l *Layer) BackgroundEviction(ctx context.Context, dur time.Duration)

func (*Layer) Delete

func (l *Layer) Delete(name string) error

func (*Layer) Exists

func (l *Layer) Exists(name string) bool

func (*Layer) Get

func (l *Layer) Get(name string) ([]byte, error)

func (*Layer) Put

func (l *Layer) Put(name string, content []byte) error

func (*Layer) Stats

func (l *Layer) Stats() *LayerStats

type LayerStats

type LayerStats struct {
	Count int32
	Size  int64
}

type List

type List[T any] struct {
	// contains filtered or unexported fields
}

List represents a doubly linked list. The zero value for List is an empty list ready to use.

func NewList

func NewList[T any]() *List[T]

New returns an initialized list.

func (*List[T]) Back

func (l *List[T]) Back() *Element[T]

Back returns the last element of list l or nil if the list is empty.

func (*List[T]) Front

func (l *List[T]) Front() *Element[T]

Front returns the first element of list l or nil if the list is empty.

func (*List[T]) Init

func (l *List[T]) Init() *List[T]

Init initializes or clears list l.

func (*List[T]) InsertAfter

func (l *List[T]) InsertAfter(v T, mark *Element[T]) *Element[T]

InsertAfter inserts a new element e with value v immediately after mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.

func (*List[T]) InsertBefore

func (l *List[T]) InsertBefore(v T, mark *Element[T]) *Element[T]

InsertBefore inserts a new element e with value v immediately before mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.

func (*List[T]) Len

func (l *List[T]) Len() int

Len returns the number of elements of list l. The complexity is O(1).

func (*List[T]) MoveAfter

func (l *List[T]) MoveAfter(e, mark *Element[T])

MoveAfter moves element e to its new position after mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.

func (*List[T]) MoveBefore

func (l *List[T]) MoveBefore(e, mark *Element[T])

MoveBefore moves element e to its new position before mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.

func (*List[T]) MoveToBack

func (l *List[T]) MoveToBack(e *Element[T])

MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified. The element must not be nil.

func (*List[T]) MoveToFront

func (l *List[T]) MoveToFront(e *Element[T])

MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified. The element must not be nil.

func (*List[T]) PushBack

func (l *List[T]) PushBack(v T) *Element[T]

PushBack inserts a new element e with value v at the back of list l and returns e.

func (*List[T]) PushBackList

func (l *List[T]) PushBackList(other *List[T])

PushBackList inserts a copy of another list at the back of list l. The lists l and other may be the same. They must not be nil.

func (*List[T]) PushFront

func (l *List[T]) PushFront(v T) *Element[T]

PushFront inserts a new element e with value v at the front of list l and returns e.

func (*List[T]) PushFrontList

func (l *List[T]) PushFrontList(other *List[T])

PushFrontList inserts a copy of another list at the front of list l. The lists l and other may be the same. They must not be nil.

func (*List[T]) Remove

func (l *List[T]) Remove(e *Element[T]) any

Remove removes e from l if e is an element of list l. It returns the element value e.Value. The element must not be nil.

type MaxCacheSizeEviction

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

func NewMaxCacheSizeEviction

func NewMaxCacheSizeEviction(size int64) *MaxCacheSizeEviction

type MaxItemsEviction

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

func NewMaxItemsEviction

func NewMaxItemsEviction(number int) *MaxItemsEviction

type Memory

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

func NewMemory

func NewMemory() *Memory

func (*Memory) Delete

func (m *Memory) Delete(name string) error

func (*Memory) Exists

func (m *Memory) Exists(name string) bool

func (*Memory) Get

func (m *Memory) Get(name string) ([]byte, error)

func (*Memory) Put

func (m *Memory) Put(name string, content []byte) error

type NestedFileSystem

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

func NewNestedFilesystem

func NewNestedFilesystem(path string, numSubdirectories uint) (*NestedFileSystem, error)

func (*NestedFileSystem) Delete

func (nfs *NestedFileSystem) Delete(name string) error

func (*NestedFileSystem) Exists

func (nfs *NestedFileSystem) Exists(name string) bool

func (*NestedFileSystem) Get

func (nfs *NestedFileSystem) Get(name string) ([]byte, error)

func (*NestedFileSystem) Put

func (nfs *NestedFileSystem) Put(name string, content []byte) error

type Storer

type Storer interface {
	Exists(name string) bool
	Get(name string) ([]byte, error)
}

Jump to

Keyboard shortcuts

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