cache

package
v0.35.21 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Unlicense Imports: 3 Imported by: 18 modules, 26 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cache provides a simple LRU cache implementation

Deprecated: Use cache/bytecache instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Set data
	// Return FALSE if data was added;  TRUE if data was replaced
	Set(key, val []byte) bool

	// Get data
	// Return nil if item with this key doesn't exist
	Get(key []byte) []byte

	// Delete data
	Del(key []byte)

	// Clear all data and statistics
	Clear()

	// Get statistics data
	Stats() Stats
}

Cache - interface

func New

func New(conf Config) Cache

New - create cache object

type Config

type Config struct {
	// Max. cache size (in bytes) of keys and values.  Default: unlimited
	MaxSize uint

	// Max. element size (in bytes).  Default: =MaxSize
	MaxElementSize uint

	// Max. elements number.  Default: unlimited
	MaxCount uint

	// When cache is full, the least recently used element is deleted automatically
	EnableLRU bool

	// User callback function which is called after an element has been deleted automatically
	OnDelete onDeleteType
}

Config - configuration

type Stats

type Stats struct {
	Count int
	Size  int
	Hit   int
	Miss  int
}

Stats - counters

Directories

Path Synopsis
Package bytecache provides a simple LRU cache implementation that takes size into account.
Package bytecache provides a simple LRU cache implementation that takes size into account.

Jump to

Keyboard shortcuts

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