cache

package
v0.24.9 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheMiss = errors.New("lets proxy: cache miss")

Functions

This section is empty.

Types

type Bytes

type Bytes interface {
	// Get returns a certificate data for the specified key.
	// If there's no such key, Get returns ErrCacheMiss.
	Get(ctx context.Context, key string) ([]byte, error)

	// Put stores the data in the cache under the specified key.
	// Underlying implementations may use any data storage format,
	// as long as the reverse operation, Get, results in the original data.
	Put(ctx context.Context, key string, data []byte) error

	// Delete removes a certificate data from the cache under the specified key.
	// If there's no such key in the cache, Delete returns nil.
	Delete(ctx context.Context, key string) error
}

type DiskCache

type DiskCache struct {
	Dir string
	// contains filtered or unexported fields
}

func (*DiskCache) Delete

func (c *DiskCache) Delete(ctx context.Context, key string) error

func (*DiskCache) Get

func (c *DiskCache) Get(ctx context.Context, key string) ([]byte, error)

func (*DiskCache) Put

func (c *DiskCache) Put(ctx context.Context, key string, data []byte) error

type MemoryCache

type MemoryCache struct {
	Name string // use for log
	// contains filtered or unexported fields
}

func NewMemoryCache

func NewMemoryCache(name string) *MemoryCache

func (*MemoryCache) Delete

func (c *MemoryCache) Delete(ctx context.Context, key string) (err error)

func (*MemoryCache) Get

func (c *MemoryCache) Get(ctx context.Context, key string) (data []byte, err error)

func (*MemoryCache) Put

func (c *MemoryCache) Put(ctx context.Context, key string, data []byte) (err error)

type MemoryValueLRU

type MemoryValueLRU struct {
	// Must not change concurrency with usage
	Name       string // use for log
	MaxSize    int
	CleanCount int
	// contains filtered or unexported fields
}

func NewMemoryValueLRU

func NewMemoryValueLRU(name string) *MemoryValueLRU

func (*MemoryValueLRU) Delete

func (c *MemoryValueLRU) Delete(ctx context.Context, key string) (err error)

func (*MemoryValueLRU) Get

func (c *MemoryValueLRU) Get(ctx context.Context, key string) (value interface{}, err error)

func (*MemoryValueLRU) Put

func (c *MemoryValueLRU) Put(ctx context.Context, key string, value interface{}) (err error)

type Value

type Value interface {
	// Get returns a certificate data for the specified key.
	// If there's no such key, Get returns ErrCacheMiss.
	Get(ctx context.Context, key string) (interface{}, error)

	// Put stores the data in the cache under the specified key.
	// Underlying implementations may use any data storage format,
	// as long as the reverse operation, Get, results in the original data.
	Put(ctx context.Context, key string, value interface{}) error

	// Delete removes a certificate data from the cache under the specified key.
	// If there's no such key in the cache, Delete returns nil.
	Delete(ctx context.Context, key string) error
}

Jump to

Keyboard shortcuts

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