cache

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadableSize

func ReadableSize(bytes int64) string

returns a human-readable size format for the given number of bytes.

Types

type ByteSize

type ByteSize float64
const (
	KB ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
	PB
	EB
	ZB
	YB
)

func (ByteSize) String

func (b ByteSize) String() string

String returns a human-readable representation of a ByteSize.

type Cache

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

Cache represents a least recently used (LRU) cache.

func New

func New(maxSizeMB int64) (*Cache, error)

New creates a new LRU cache with the specified size.

func (*Cache) Get

func (c *Cache) Get(key interface{}) (interface{}, bool, error)

Get retrieves the value associated with the given key.

func (*Cache) Put

func (c *Cache) Put(key, value interface{}) error

Put adds or updates a key-value pair in the cache.

func (*Cache) SizeOf

func (c *Cache) SizeOf() int64

SizeOf returns the approximate memory usage in bytes of the cache.

type Entry

type Entry struct {
	Key   interface{}
	Value interface{}
}

Entry represents a key-value pair in the cache.

Jump to

Keyboard shortcuts

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