Skip to content

nuczzz/lru

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lru

LRU algorithm written in golang, NOT thread-safe.

Example

package main

import (
	"fmt"

	"github.com/nuczzz/lru"
)

type value struct {
	data string
}

func (v value) Len() int64 {
	return int64(len(v.data))
}

func main() {
	l := lru.NewLRU(100, 40)
	l.AddNewNode("key1", value{"value1"})
	l.AddNewNode("key2", value{"value2"})
	list := l.Traversal()
	for i := range list {
		fmt.Printf("%#v\n", list[i])
	}
}

About

LRU algorithm written in golang.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages