cachekit

package
v0.0.0-...-9e9b37c Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewNoOpCache

func NewNoOpCache() *Cache

func (Cache) Get

func (c Cache) Get(ctx context.Context, key []byte) []byte

func (Cache) GetFunc

func (c Cache) GetFunc(ctx context.Context, key []byte, ttl time.Duration, f func(key []byte) []byte) []byte

func (Cache) GetFuncErr

func (c Cache) GetFuncErr(ctx context.Context, key []byte, ttl time.Duration, f func(key []byte) ([]byte, error)) ([]byte, error)

func (Cache) GetGobFuncErr

func (c Cache) GetGobFuncErr(ctx context.Context, key []byte, ttl time.Duration, output interface{}, f func(key []byte) (interface{}, error)) error

func (Cache) Remove

func (c Cache) Remove(ctx context.Context, key []byte)

func (Cache) Set

func (c Cache) Set(ctx context.Context, key, value []byte, ttl time.Duration)

type DiskCache

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

func NewDiskCache

func NewDiskCache(ctx context.Context, filename string, maxSize int64) (*DiskCache, error)

func (*DiskCache) Close

func (d *DiskCache) Close() error

func (*DiskCache) Evict

func (d *DiskCache) Evict(ctx context.Context, maxSize int64)

func (*DiskCache) GetCache

func (d *DiskCache) GetCache(ctx context.Context, prefix string) *Cache

type DiskCache2

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

func NewDiskCache2

func NewDiskCache2(ctx context.Context, basePath string, maxSize int64) (*DiskCache2, error)

func (*DiskCache2) Close

func (cache *DiskCache2) Close()

func (*DiskCache2) Get

func (cache *DiskCache2) Get(ctx context.Context, keyHash dc2Hash) []byte

func (*DiskCache2) GetCache

func (cache *DiskCache2) GetCache(_ context.Context, prefix string) *Cache

func (*DiskCache2) Remove

func (cache *DiskCache2) Remove(ctx context.Context, keyHash dc2Hash) bool

func (*DiskCache2) Set

func (cache *DiskCache2) Set(ctx context.Context, keyHash dc2Hash, value []byte, ttl time.Duration)

func (*DiskCache2) Stats

func (cache *DiskCache2) Stats() DiskCache2Stats

type DiskCache2Stats

type DiskCache2Stats struct {
	EstimatedSize  int64
	EstimatedCount int64

	Misses    int64
	Hits      int64
	Evictions int64

	WrittenBytes int64
	ReadBytes    int64
	DeletedBytes int64
}

type MemoryCache

type MemoryCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewMemoryCache

func NewMemoryCache(byteSize int) *MemoryCache

func (*MemoryCache) GetCache

func (d *MemoryCache) GetCache(prefix string) *Cache

Jump to

Keyboard shortcuts

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