tinybox

package module
v0.0.0-...-064b614 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 2 Imported by: 0

README

tinybox

a very simple cache pkg

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(size int) *Cache

func (*Cache) Get

func (c *Cache) Get(key string) (value []byte, ok bool)

func (*Cache) Set

func (c *Cache) Set(key string, value []byte)

type Item

type Item[T any] struct {
	// contains filtered or unexported fields
}

type LRU

type LRU[T any] struct {
	// contains filtered or unexported fields
}

LRU is a LRU container. It is not safe for concurrent access for now.

func NewLRU

func NewLRU[T any](maxBytes int, onEvicted func(key string, value T)) *LRU[T]

func (*LRU[T]) Add

func (l *LRU[T]) Add(key string, val T, size int)

Add adds a new key-value pair to the LRU.

func (*LRU[T]) Get

func (l *LRU[T]) Get(key string) (value T, ok bool)

Get lookups the mapped value by key.

type Payload

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

func (Payload) Bytes

func (p Payload) Bytes() []byte

func (Payload) Len

func (p Payload) Len() int

Jump to

Keyboard shortcuts

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