cache

package
v0.0.0-...-4ff26d5 Latest Latest
Warning

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

Go to latest
Published: May 4, 2014 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package cache provides interfaces for cache functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Set(k Key, d Data)

	Get(k Key) (Data, bool)

	Delete(k Key)

	// Size returns the count in bytes of the cache
	Size() uint64

	ElementsCount() uint64

	Clear()

	Evict(n int)

	Capacity() uint64

	SetCapacity(cap uint64)

	// Full returns whether current cache is full or not
	Full() bool
}

Cache is the common interface implemented by all cache functions

type Data

type Data interface {

	// Size returns the count in bytes of this data
	Size() uint64
}

Data is the interface to insert data to the cache

type Key

type Key interface{}

type Option

type Option interface {

	// Capacity returns the current max allowed bytes
	// to store in the cache
	// Zero means no limitation.
	Capacity() uint64

	// SetCapacity sets the max allowed bytes
	// to store in the cache
	// Zero means no limitation.
	SetCapacity(cap uint64)

	// MaxElements returns current max elements totally
	// to store in the cache
	// Zero means no limitation.
	MaxElements() uint64

	// SetMaxElements sets the max count of elements
	// to store in the cache.
	// Zero means no limitation.
	SetMaxElements(count uint64)
}

Directories

Path Synopsis
This package implements a O(1) LFU Followed the origin paper http://dhruvbird.com/lfu.pdf
This package implements a O(1) LFU Followed the origin paper http://dhruvbird.com/lfu.pdf
Package lru provides one implementation of the LRU cache
Package lru provides one implementation of the LRU cache

Jump to

Keyboard shortcuts

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