cache

package
v0.0.0-...-08f17c8 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: BSD-3-Clause Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheEntry

type CacheEntry interface {
	GetKey() string
	GetGroup() string
	GetSize() int
	GetCreationTime() time.Time

	GetData(buffer []byte, inBlockOffset int) (int, error)
	ReadData(writer io.Writer, inBlockOffset int) (int, error)
}

CacheEntry is a cache entry (e.g., a file chunk)

type CacheStore

type CacheStore interface {
	Release()

	GetEntrySizeCap() int
	GetSizeCap() int64

	GetTotalEntries() int
	GetTotalEntrySize() int64
	GetAvailableSize() int64

	DeleteAllEntries()
	DeleteAllEntriesForGroup(group string)

	GetEntryKeys() []string
	GetEntryKeysForGroup(group string) []string

	CreateEntry(key string, group string, data []byte) (CacheEntry, error)
	HasEntry(key string) bool
	GetEntry(key string) CacheEntry
	DeleteEntry(key string)
}

CacheStore is a cache management object

func NewDiskCacheStore

func NewDiskCacheStore(sizeCap int64, entrySizeCap int, rootPath string) (CacheStore, error)

NewDiskCacheStore creates a new DiskCacheStore

type DiskCacheEntry

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

DiskCacheEntry implements CacheEntry

func NewDiskCacheEntry

func NewDiskCacheEntry(cache *DiskCacheStore, key string, group string, data []byte) (*DiskCacheEntry, error)

NewDiskCacheEntry creates a new DiskCacheEntry

func (*DiskCacheEntry) GetCreationTime

func (entry *DiskCacheEntry) GetCreationTime() time.Time

GetKey returns creation time of the entry

func (*DiskCacheEntry) GetData

func (entry *DiskCacheEntry) GetData(buffer []byte, inBlockOffset int) (int, error)

GetKey returns data of the entry

func (*DiskCacheEntry) GetGroup

func (entry *DiskCacheEntry) GetGroup() string

GetKey returns group of the entry

func (*DiskCacheEntry) GetKey

func (entry *DiskCacheEntry) GetKey() string

GetKey returns key of the entry

func (*DiskCacheEntry) GetSize

func (entry *DiskCacheEntry) GetSize() int

GetKey returns the size of the entry

func (*DiskCacheEntry) ReadData

func (entry *DiskCacheEntry) ReadData(writer io.Writer, inBlockOffset int) (int, error)

ReadData returns data of the entry

type DiskCacheStore

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

DiskCacheStore implements CacheStore

func (*DiskCacheStore) CreateEntry

func (store *DiskCacheStore) CreateEntry(key string, group string, data []byte) (CacheEntry, error)

CreateEntry creates a new entry

func (*DiskCacheStore) DeleteAllEntries

func (store *DiskCacheStore) DeleteAllEntries()

DeleteAllEntries deletes all entries

func (*DiskCacheStore) DeleteAllEntriesForGroup

func (store *DiskCacheStore) DeleteAllEntriesForGroup(group string)

DeleteAllEntriesForGroup deletes all entries in the given group

func (*DiskCacheStore) DeleteEntry

func (store *DiskCacheStore) DeleteEntry(key string)

DeleteEntry deletes an entry with the given key

func (*DiskCacheStore) GetAvailableSize

func (store *DiskCacheStore) GetAvailableSize() int64

GetAvailableSize returns available disk space

func (*DiskCacheStore) GetEntry

func (store *DiskCacheStore) GetEntry(key string) CacheEntry

GetEntry returns an entry with the given key

func (*DiskCacheStore) GetEntryKeys

func (store *DiskCacheStore) GetEntryKeys() []string

GetEntryKeys returns all entry keys

func (*DiskCacheStore) GetEntryKeysForGroup

func (store *DiskCacheStore) GetEntryKeysForGroup(group string) []string

GetEntryKeysForGroup returns all entry keys for the given group

func (*DiskCacheStore) GetEntrySizeCap

func (store *DiskCacheStore) GetEntrySizeCap() int

GetEntrySizeCap returns entry size cap

func (*DiskCacheStore) GetRootPath

func (store *DiskCacheStore) GetRootPath() string

GetRootPath returns root path of disk cache

func (*DiskCacheStore) GetSizeCap

func (store *DiskCacheStore) GetSizeCap() int64

GetSizeCap returns size cap

func (*DiskCacheStore) GetTotalEntries

func (store *DiskCacheStore) GetTotalEntries() int

GetTotalEntries returns total number of entries in cache

func (*DiskCacheStore) GetTotalEntrySize

func (store *DiskCacheStore) GetTotalEntrySize() int64

GetTotalEntrySize returns total size of entries in cache

func (*DiskCacheStore) HasEntry

func (store *DiskCacheStore) HasEntry(key string) bool

HasEntry checks if the entry for the given key is present

func (*DiskCacheStore) Release

func (store *DiskCacheStore) Release()

Release releases resources

Jump to

Keyboard shortcuts

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