textbuffer

package
v0.1.0-experimental.3 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package textbuffer provides (as a first rough prototype) handling of cached byte buffers.

Clients create a *TextBuffer, which caches portions of bytes of an io.ReaderAt. The text buffer implements io.ReaderAt itself, thus may be used in the same fashion as the underlying reader.

reader := strings.NewReader("The quick brown fox jumps over the lazy dog.")
cache := textbuffer.NewCache(reader, 3)
bytebuf := make([]byte, 10)
n, err := cache.ReadAt(bytebuf, 4) // reads "quick..."

Index

Constants

View Source
const BufferSize = 10
View Source
const DefaultCacheBufferCount = 3
View Source
const RecycleTimeout = 2 * time.Second

const RecycleTimeout = time.Minute

Variables

This section is empty.

Functions

This section is empty.

Types

type TextBuffer

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

func NewBuffer

func NewBuffer() *TextBuffer

Create a text buffer. Will use DefaultBufferSize, if buffersize is 0.

func (*TextBuffer) String

func (tbuf *TextBuffer) String() string

type TextCache

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

func NewCache

func NewCache(reader io.ReaderAt, buffercount int) *TextCache

func (*TextCache) Dump

func (cache *TextCache) Dump()

func (*TextCache) ReadAt

func (cache *TextCache) ReadAt(buffer []byte, offset int64) (N int, err error)

Jump to

Keyboard shortcuts

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