tcache

package
v1.0.54 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferPool

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

BufferPool is a 'buffer pool'.

func NewBufferPool

func NewBufferPool(baseline int) *BufferPool

NewBufferPool creates a new initialized 'buffer pool'.

func (*BufferPool) Get

func (p *BufferPool) Get(n int) []byte

Get returns buffer with length of n.

func (*BufferPool) Put

func (p *BufferPool) Put(b []byte)

Put adds given buffer to the pool.

func (*BufferPool) String

func (p *BufferPool) String() string

type ChanBuffer

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

ChanBuffer 基于channel实现的缓冲区

func NewChanBuffer

func NewChanBuffer[T any](fetcher ttypes.FetchHandler[T], resultLen int, timeout time.Duration) *ChanBuffer[T]

func (*ChanBuffer[T]) Close

func (c *ChanBuffer[T]) Close()

func (*ChanBuffer[T]) Get

func (c *ChanBuffer[T]) Get() (T, error)

type IBufferPool

type IBufferPool interface {
	Get(n int) []byte
	Put(b []byte)
}

type ICacheBuffer

type ICacheBuffer[T any] interface {
	Close()
	Get() (T, error)
}

func NewCacheBuffer

func NewCacheBuffer[T any](fetcher ttypes.FetchHandler[T]) ICacheBuffer[T]

type MemCache added in v1.0.33

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

MemCache 轻量级即插即用的map缓存,只能用于局部cache

func NewMemCache added in v1.0.33

func NewMemCache[K comparable, V any]() *MemCache[K, V]

func (*MemCache[K, V]) Get added in v1.0.33

func (m *MemCache[K, V]) Get(key K) (V, bool)

func (*MemCache[K, V]) Load added in v1.0.33

func (m *MemCache[K, V]) Load(key K, value V)

Jump to

Keyboard shortcuts

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