ds

package
v0.0.0-...-3386cd4 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Provides leaky buffer, based on the example in Effective Go.

Index

Constants

View Source
const (
	GlobalLeakyBufSize = 4108 // data.len(2) + hmacsha1(10) + data(4096)

)

Variables

View Source
var GlobalLeakyBuf = NewLeakyBuf(maxNBuf, GlobalLeakyBufSize)

Functions

This section is empty.

Types

type ItemMap

type ItemMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewItemMap

func NewItemMap(file string, autoApplyChanges bool) *ItemMap

func NewItemMapWithCap

func NewItemMapWithCap(file string, autoApplyChanges bool, cap int) *ItemMap

func (*ItemMap) AddItem

func (this *ItemMap) AddItem(key string)

func (*ItemMap) Clear

func (this *ItemMap) Clear()

func (*ItemMap) Hit

func (this *ItemMap) Hit(item string) bool

func (*ItemMap) IsEmpty

func (this *ItemMap) IsEmpty() bool

func (*ItemMap) Load

func (this *ItemMap) Load() bool

func (*ItemMap) MonitorFileChange

func (this *ItemMap) MonitorFileChange()

func (*ItemMap) Save

func (this *ItemMap) Save() bool

type ItemTree

type ItemTree struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewItemTree

func NewItemTree(file string, autoApplyChanges bool) *ItemTree

func (*ItemTree) AddItem

func (this *ItemTree) AddItem(key string)

func (*ItemTree) Clear

func (this *ItemTree) Clear()

func (*ItemTree) Hit

func (this *ItemTree) Hit(item string) bool

func (*ItemTree) IsEmpty

func (this *ItemTree) IsEmpty() bool

func (*ItemTree) Load

func (this *ItemTree) Load() bool

func (*ItemTree) MonitorFileChange

func (this *ItemTree) MonitorFileChange()

func (*ItemTree) Save

func (this *ItemTree) Save() bool

type LeakyBuf

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

func NewLeakyBuf

func NewLeakyBuf(n, bufSize int) *LeakyBuf

NewLeakyBuf creates a leaky buffer which can hold at most n buffer, each with bufSize bytes.

func (*LeakyBuf) Get

func (lb *LeakyBuf) Get() (b []byte)

Get returns a buffer from the leaky buffer or create a new buffer.

func (*LeakyBuf) Put

func (lb *LeakyBuf) Put(b []byte)

Put add the buffer into the free buffer pool for reuse. Panic if the buffer size is not the same with the leaky buffer's. This is intended to expose error usage of leaky buffer.

Jump to

Keyboard shortcuts

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