utils

package
v0.3.1-beta Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//B .
	B Unit = 0
	//KB .
	KB Unit = 1
	//MB .
	MB Unit = 2
	//GB .
	GB Unit = 3
	//TB .
	TB Unit = 4
	//PB .
	PB Unit = 5
	//B2 .
	B2 = "B"
	//KB2 .
	KB2 = "KB"
	//MB2 .
	MB2 = "MB"
	//GB2 .
	GB2 = "GB"
	//TB2 .
	TB2 = "TB"
	//PB2 .
	PB2 = "PB"
)
View Source
var DefaultSize = 8 * 0x400

Functions

func Copy

func Copy(dst io.Writer, src io.Reader) (err error)

func GetBytes

func GetBytes(size int) []byte

func PutBytes

func PutBytes(b []byte)

func ReducedUnitToString

func ReducedUnitToString(byte float64) (result string)

ReducedUnitToString .

func Relay

func Relay(local, remote io.ReadWriter)

Relay pipe

Types

type Cache

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

Cache use map save history

func NewCache

func NewCache() *Cache

NewCache create new cache

func (*Cache) Add

func (c *Cache) Add(domain string, mark interface{})

Add .

func (*Cache) Get

func (c *Cache) Get(domain string) (interface{}, bool)

Get .

type LRU

type LRU[K, V any] struct {
	// contains filtered or unexported fields
}

LRU Least Recently Used

func NewLru

func NewLru[K, V any](capacity int, timeout time.Duration) *LRU[K, V]

NewLru create new lru cache

func (*LRU[K, V]) Add

func (l *LRU[K, V]) Add(key K, value V)

func (*LRU[K, V]) Delete

func (l *LRU[K, V]) Delete(key K)

Delete delete a key from cache

func (*LRU[K, V]) Load

func (l *LRU[K, V]) Load(key K) (v V, ok bool)

type Unit

type Unit int

Unit .

func ReducedUnit

func ReducedUnit(byte float64) (result float64, unit Unit)

ReducedUnit .

Jump to

Keyboard shortcuts

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