generic_lru

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

README

Go - Generic LRU

This repo is based on the github.com/golang/groupcache/lru package. See https://github.com/golang/groupcache/tree/master/lru for more information.

Packages

github.com/gsxab/go-generic_lru with package name generic_lru

Cache[Key, Value] as a generic interface for the concrete cache implementations.

github.com/gsxab/go-generic_lru/lru

A naive LRU cache based on a linked list and a map.

github.com/gsxab/go-generic_lru/with_lock

A decorator wrapping a Cache[Key, Value] with a sync.Locker. It locks the container for every r/w operations.

github.com/gsxab/go-generic_lru/with_rw_lock

A decorator wrapping a Cache[Key, Value] with a RWMutex-like locker. It locks the container with a readers-writer lock for reading and writing operations accordingly.

github.com/gsxab/go-generic_lru/lru_with_lock, github.com/gsxab/go-generic_lru/lru_with_rw_lock

Shortcuts to create lock-wrapped LRU caches.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[Key comparable, Value any] interface {
	Add(key Key, value Value)
	Get(key Key) (value Value, ok bool)
	Remove(key Key) (value Value, ok bool)
	RemoveOldest() (key Key, value Value, ok bool)
	GetOldest() (key Key, value Value, ok bool)
	ApplyRO(f func(Cache[Key, Value]))
	ApplyRW(f func(Cache[Key, Value]))
	Len() int
	Container() (interface{}, error)
	Clear()
}

Directories

Path Synopsis
Package lru implements an LRU cache.
Package lru implements an LRU cache.

Jump to

Keyboard shortcuts

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