fastcache

package
v0.0.0-...-ca3ac9b Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package fastcache implementing a fast cache in memory and fast file storage

Index

Constants

View Source
const (
	// BinaryExt extension for binary files
	BinaryExt = ".bin"
	// Defaultmffrs this is the max size of a blob that will be stored into memory, if possible
	Defaultmffrs = 100 * 1024
	// DefaultTnt the default tenant. Because this storage isn't tenant specific
	DefaultTnt = "n.n."
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FastCache

type FastCache struct {
	RootPath          string // this is the root path for the file system storage
	MaxCount          int64
	MaxRAMSize        int64
	MaxFileSizeForRAM int64
	// contains filtered or unexported fields
}

FastCache a fast cache implementation using a mix of memory and fast ssd storage

func (*FastCache) AddRetention

func (f *FastCache) AddRetention(_ *model.RetentionEntry) error

AddRetention adding a retention entry to the storage

func (*FastCache) CheckBlob

func (f *FastCache) CheckBlob(id string) (*model.CheckInfo, error)

CheckBlob checking a single blob from the storage system

func (*FastCache) Close

func (f *FastCache) Close() error

Close closing the storage

func (*FastCache) DeleteBlob

func (f *FastCache) DeleteBlob(id string) error

DeleteBlob removing a blob from the storage system

func (*FastCache) DeleteRetention

func (f *FastCache) DeleteRetention(_ string) error

DeleteRetention deletes the retention entry from the storage

func (*FastCache) GetAllRetentions

func (f *FastCache) GetAllRetentions(_ func(r model.RetentionEntry) bool) error

GetAllRetentions for every retention entry for this tenant we call this this function, you can stop the listing by returning a false

func (*FastCache) GetBlobDescription

func (f *FastCache) GetBlobDescription(id string) (*model.BlobDescription, error)

GetBlobDescription getting the description of the file

func (*FastCache) GetBlobs

func (f *FastCache) GetBlobs(callback func(id string) bool) error

GetBlobs getting a list of blob from the storage

func (*FastCache) GetLastError

func (f *FastCache) GetLastError() error

GetLastError returning the last error (niy)

func (*FastCache) GetRetention

func (f *FastCache) GetRetention(_ string) (model.RetentionEntry, error)

GetRetention getting a single retention entry

func (*FastCache) GetTenant

func (f *FastCache) GetTenant() string

GetTenant get the tenant id, niy

func (*FastCache) HasBlob

func (f *FastCache) HasBlob(id string) (bool, error)

HasBlob checking, if a blob is present

func (*FastCache) Init

func (f *FastCache) Init() error

Init initialize this service

func (*FastCache) ResetRetention

func (f *FastCache) ResetRetention(_ string) error

ResetRetention resets the retention for a blob

func (*FastCache) RetrieveBlob

func (f *FastCache) RetrieveBlob(id string, w io.Writer) error

RetrieveBlob retrieving the binary data from the storage system

func (*FastCache) SearchBlobs

func (f *FastCache) SearchBlobs(_ string, _ func(id string) bool) error

SearchBlobs querying a single blob, niy

func (*FastCache) StoreBlob

func (f *FastCache) StoreBlob(b *model.BlobDescription, r io.Reader) (string, error)

StoreBlob storing a blob to the storage system

func (*FastCache) UpdateBlobDescription

func (f *FastCache) UpdateBlobDescription(id string, b *model.BlobDescription) error

UpdateBlobDescription updating the blob description

type LRUEntry

type LRUEntry struct {
	LastAccess  time.Time             `json:"lastAccess"`
	Description model.BlobDescription `json:"description"`
	Data        []byte                `json:"data"`
}

LRUEntry one lru list entry

type LRUList

type LRUList struct {
	MaxCount   int
	MaxRAMSize int64
	// contains filtered or unexported fields
}

LRUList the full ist of lru entries

func (*LRUList) Add

func (l *LRUList) Add(e LRUEntry) bool

Add add a new entry to the list

func (*LRUList) Delete

func (l *LRUList) Delete(id string) string

Delete removing an entry from the list

func (*LRUList) Get

func (l *LRUList) Get(id string) (LRUEntry, bool)

Get getting an entry if present

func (*LRUList) GetFullIDList

func (l *LRUList) GetFullIDList() []string

GetFullIDList getting a copy of the full id list of all entries

func (*LRUList) HandleContrains

func (l *LRUList) HandleContrains() string

HandleContrains doing the self reoganising

func (*LRUList) Has

func (l *LRUList) Has(id string) bool

Has checking the existence of an entry

func (*LRUList) Init

func (l *LRUList) Init()

Init initialise this LRU list

func (*LRUList) Size

func (l *LRUList) Size() int

Size getting the size of the list

func (*LRUList) Update

func (l *LRUList) Update(e LRUEntry)

Update an entry

func (*LRUList) UpdateAccess

func (l *LRUList) UpdateAccess(id string)

UpdateAccess updates the access time of an entry

Jump to

Keyboard shortcuts

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