cache

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMsgCorrupted = errors.New("ecrypted file was corrupted")
	ErrLowSpace     = errors.New("not enough free space left on device")
)
View Source
var ErrCacheNeedsUnlock = errors.New("cache needs to be unlocked")

Functions

func IsOnDiskCache

func IsOnDiskCache(c Cache) bool

IsOnDiskCache will return true if Cache is type of onDiskCache.

Types

type Cache

type Cache interface {
	Unlock(userID string, passphrase []byte) error
	Lock(userID string)
	Delete(userID string) error

	Has(userID, messageID string) bool
	Get(userID, messageID string) ([]byte, error)
	Set(userID, messageID string, literal []byte) error
	Rem(userID, messageID string) error
}

func NewInMemoryCache

func NewInMemoryCache(limit int) Cache

NewInMemoryCache creates a new in memory cache which stores up to the given number of bytes of cached data. NOTE(GODT-1158): Make this threadsafe.

func NewOnDiskCache

func NewOnDiskCache(path string, cmp Compressor, opts Options) (Cache, error)

type Compressor

type Compressor interface {
	Compress([]byte) ([]byte, error)
	Decompress([]byte) ([]byte, error)
}

type GZipCompressor

type GZipCompressor struct{}

func (GZipCompressor) Compress

func (GZipCompressor) Compress(dec []byte) ([]byte, error)

func (GZipCompressor) Decompress

func (GZipCompressor) Decompress(cmp []byte) ([]byte, error)

type NoopCompressor

type NoopCompressor struct{}

func (NoopCompressor) Compress

func (NoopCompressor) Compress(dec []byte) ([]byte, error)

func (NoopCompressor) Decompress

func (NoopCompressor) Decompress(cmp []byte) ([]byte, error)

type Options

type Options struct {
	MinFreeAbs      uint64
	MinFreeRat      float64
	ConcurrentRead  int
	ConcurrentWrite int
}

Jump to

Keyboard shortcuts

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