Skip to content
This repository was archived by the owner on Aug 14, 2026. It is now read-only.
floatdropPublic archive

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

64 stars

Watchers

2 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

2q

Go Reference CI Coverage Go Report Card

Thread safe GoLang 2Q cache.

Example

import (
	"fmt"

	twoqueue "github.com/floatdrop/2q"
)

func main() {
	cache := twoqueue.New[string, int](256)

	cache.Set("Hello", 5)

	if e := cache.Get("Hello"); e != nil {
		fmt.Println(*e)
		// Output: 5
	}
}

TTL

See LRU TTL example.

Benchmarks

floatdrop/twoqueue:
	Benchmark2Q_Rand-8   	 4384994	       264.5 ns/op	      46 B/op	       3 allocs/op
	Benchmark2Q_Freq-8   	 4862632	       243.9 ns/op	      44 B/op	       3 allocs/op

hashicorp/golang-lru:
	Benchmark2Q_Rand-8    	 2847627	       411.9 ns/op	     135 B/op	       5 allocs/op
	Benchmark2Q_Freq-8    	 3323764	       354.2 ns/op	     122 B/op	       5 allocs/op

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

64 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages