cache

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[K comparable, V any] interface {
	Set(key K, value V)
	Get(key K) (V, bool)
	Del(key K)
	Contains(key K) bool
	Peek(key K) (V, bool)
	Purge()
	Keys() []K
	Len() int
}

type ShardedCache

type ShardedCache[K string, V any] struct {
	// contains filtered or unexported fields
}

func NewShardedCache

func NewShardedCache[K string, V any](
	numShards int,
	sizePerShard int,
	cacheFactory func(size int) Cache[K, V],
) *ShardedCache[K, V]

func (*ShardedCache[K, V]) Del

func (sc *ShardedCache[K, V]) Del(key K)

func (*ShardedCache[K, V]) Get

func (sc *ShardedCache[K, V]) Get(key K) (V, bool)

func (*ShardedCache[K, V]) Len

func (sc *ShardedCache[K, V]) Len() int

func (*ShardedCache[K, V]) Set

func (sc *ShardedCache[K, V]) Set(key K, value V)

type TwoQueue

type TwoQueue[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func New2Q

func New2Q[K comparable, V any](capacity int) *TwoQueue[K, V]

func (*TwoQueue[K, V]) Contains

func (c *TwoQueue[K, V]) Contains(key K) bool

func (*TwoQueue[K, V]) Del

func (c *TwoQueue[K, V]) Del(key K)

func (*TwoQueue[K, V]) Get

func (c *TwoQueue[K, V]) Get(key K) (V, bool)

func (*TwoQueue[K, V]) Keys

func (c *TwoQueue[K, V]) Keys() []K

func (*TwoQueue[K, V]) Len

func (c *TwoQueue[K, V]) Len() int

func (*TwoQueue[K, V]) Peek

func (c *TwoQueue[K, V]) Peek(key K) (V, bool)

func (*TwoQueue[K, V]) Purge

func (c *TwoQueue[K, V]) Purge()

func (*TwoQueue[K, V]) Set

func (c *TwoQueue[K, V]) Set(key K, value V)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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