Documentation ¶
Index ¶
- type CacheEntry
- type CacheStore
- type DiskCacheEntry
- func (entry *DiskCacheEntry) GetCreationTime() time.Time
- func (entry *DiskCacheEntry) GetData(buffer []byte, inBlockOffset int) (int, error)
- func (entry *DiskCacheEntry) GetGroup() string
- func (entry *DiskCacheEntry) GetKey() string
- func (entry *DiskCacheEntry) GetSize() int
- func (entry *DiskCacheEntry) ReadData(writer io.Writer, inBlockOffset int) (int, error)
- type DiskCacheStore
- func (store *DiskCacheStore) CreateEntry(key string, group string, data []byte) (CacheEntry, error)
- func (store *DiskCacheStore) DeleteAllEntries()
- func (store *DiskCacheStore) DeleteAllEntriesForGroup(group string)
- func (store *DiskCacheStore) DeleteEntry(key string)
- func (store *DiskCacheStore) GetAvailableSize() int64
- func (store *DiskCacheStore) GetEntry(key string) CacheEntry
- func (store *DiskCacheStore) GetEntryKeys() []string
- func (store *DiskCacheStore) GetEntryKeysForGroup(group string) []string
- func (store *DiskCacheStore) GetEntrySizeCap() int
- func (store *DiskCacheStore) GetRootPath() string
- func (store *DiskCacheStore) GetSizeCap() int64
- func (store *DiskCacheStore) GetTotalEntries() int
- func (store *DiskCacheStore) GetTotalEntrySize() int64
- func (store *DiskCacheStore) HasEntry(key string) bool
- func (store *DiskCacheStore) Release()
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
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