backtracker

package
v0.0.0-...-5044e41 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backtracker

type Backtracker interface {
	io.Reader

	// Returns the current offset (doesn't count backtracking)
	Offset() int64

	// Return amount of bytes that can be backtracked
	Cached() int64

	// Backtrack n bytes
	Backtrack(n int64) error

	// Advance n bytes
	Discard(n int64) error

	NumCacheHits() int64
	NumCacheMiss() int64

	CachedBytesServed() int64
	TotalBytesServed() int64
}

Backtracker allows reads from an io.Reader while remembering the last N bytes of data. Backtrack() can then be called, to read those bytes again.

func New

func New(offset int64, upstream io.Reader, cacheSize int64) Backtracker

New returns a Backtracker reading from upstream

Jump to

Keyboard shortcuts

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