blockcache

package
v1.91.3-cluster Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 8 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block interface {
	// SizeBytes must return the approximate size of the given block in bytes
	SizeBytes() int
}

Block is an item, which may be cached in the Cache.

type Cache

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

Cache caches Block entries.

Call NewCache() for creating new Cache.

func NewCache

func NewCache(getMaxSizeBytes func() int) *Cache

NewCache creates new cache.

Cache size in bytes is limited by the value returned by getMaxSizeBytes() callback. Call MustStop() in order to free up resources occupied by Cache.

func (*Cache) GetBlock

func (c *Cache) GetBlock(k Key) Block

GetBlock returns a block for the given key k from c.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of blocks in the cache c.

func (*Cache) Misses

func (c *Cache) Misses() uint64

Misses returns the number of cache misses for c.

func (*Cache) MustStop

func (c *Cache) MustStop()

MustStop frees up resources occupied by c.

func (*Cache) PutBlock

func (c *Cache) PutBlock(k Key, b Block)

PutBlock puts the given block b under the given key k into c.

func (*Cache) RemoveBlocksForPart

func (c *Cache) RemoveBlocksForPart(p interface{})

RemoveBlocksForPart removes all the blocks for the given part from the cache.

func (*Cache) Requests

func (c *Cache) Requests() uint64

Requests returns the number of requests served by c.

func (*Cache) SizeBytes

func (c *Cache) SizeBytes() int

SizeBytes returns an approximate size in bytes of all the blocks stored in the cache c.

func (*Cache) SizeMaxBytes

func (c *Cache) SizeMaxBytes() int

SizeMaxBytes returns the max allowed size in bytes for c.

type Key

type Key struct {
	// Part must contain a pointer to part structure where the block belongs to.
	Part interface{}

	// Offset is the offset of the block in the part.
	Offset uint64
}

Key represents a key, which uniquely identifies the Block.

Jump to

Keyboard shortcuts

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