cache

package
v1.7.18 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCapacityLRU

func NewCapacityLRU(size int, byteCapacity int64) (storage.AdaptedSizedLRUCache, error)

NewCapacityLRU constructs an LRU cache of the given size with a byte size capacity

func NewImmunityCache

func NewImmunityCache(config CacheConfig) (*immunitycache.ImmunityCache, error)

NewImmunityCache creates a new cache

func NewLRUCache

func NewLRUCache(size int) (storage.Cacher, error)

NewLRUCache returns an instance of a LRU cache

func NewLRUCacheWithEviction

func NewLRUCacheWithEviction(size int, onEvicted func(key interface{}, value interface{})) (storage.Cacher, error)

NewLRUCacheWithEviction creates a new sized LRU cache instance with eviction function

func NewTimeCache

func NewTimeCache(defaultSpan time.Duration) *timecache.TimeCache

NewTimeCache returns an instance of a time cache

func NewTimeCacher

func NewTimeCacher(arg ArgTimeCacher) (storage.Cacher, error)

NewTimeCacher creates a new timeCacher

Types

type ArgTimeCacher

type ArgTimeCacher = timecache.ArgTimeCacher

ArgTimeCacher is the argument used to create a new timeCacher instance

type CacheConfig

type CacheConfig = immunitycache.CacheConfig

CacheConfig holds cache configuration

type EvictionHandler

type EvictionHandler = types.EvictionHandler

EvictionHandler is an alias to the imported EvictionHandler

type ImmunityCache

type ImmunityCache = immunitycache.ImmunityCache

ImmunityCache is a cache-like structure

type PeerBlackListCacher

type PeerBlackListCacher interface {
	Upsert(pid core.PeerID, span time.Duration) error
	Has(pid core.PeerID) bool
	Sweep()
	IsInterfaceNil() bool
}

PeerBlackListCacher can determine if a certain peer id is or not blacklisted

func NewPeerTimeCache

func NewPeerTimeCache(cache TimeCacher) (PeerBlackListCacher, error)

NewPeerTimeCache returns an instance of a peer time cacher

type TimeCache

type TimeCache = timecache.TimeCache

TimeCache is an alias for the imported TimeCache structure

type TimeCacher

type TimeCacher interface {
	Add(key string) error
	Upsert(key string, span time.Duration) error
	Has(key string) bool
	Sweep()
	IsInterfaceNil() bool
}

TimeCacher defines the cache that can keep a record for a bounded time

Jump to

Keyboard shortcuts

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