golfu

package module
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 5 Imported by: 0

README

GOLFU

In-memory cache system

  • plug your cold storage on it to eventually persist all setted data
  • prevent some resources to be removed from the cache by implementing Evictable.CanBeEvicted on the element
  • auto eviction by read count (LFU)
  • retrieves all cache-miss from the cold storage provided and sets new elements both in cold storage and cache
  • invalidate cache entries without deleting from cold storage
  • lock-free concurrent reads via left-right map

Module tour

storage module

definition of the cached storage and cold storage

element module

any Indexable is storable, any Evictable can be kept explicitely in memory

coldstorages module

implementations of some cold storages

notes

Don't use in production.
Feel free to submit a PR or put a comment or whatever if you find a bug or wanna improve it somehow

release

increase version in README.md: Given a version number MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when you make incompatible API changes
  • MINOR version when you add functionality in a backward compatible manner
  • PATCH version when you make backward compatible bug fixes

go mod tidy
go test ./...
git commit -m "what I just did - vX.Y.Z"
git tag vX.Y.Z
git push origin vX.Y.Z
GOPROXY=proxy.golang.org go list -m github.com/JGpGH/golfu@vX.Y.Z

current version

v0.10.0

 /\
( /   @ @    ()
 \  __| |__  /
  -/   "   \-
 /-|       |-\
/ /-\     /-\ \
 / /-`---'-\ \     crab of luck
  /         \

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = lfuErr.ErrNotFound
	ErrInvalidIndex = lfuErr.ErrInvalidIndex
)

Functions

func NewCachedStorage

func NewCachedStorage[T element.Indexable](ctx context.Context, cold storage.ColdStorage[T], maxUnits int) storage.CachedStorage[T]

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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