This go module is a replication of tiny-lru written in js.
Trying to learn basic concepts of golang, implement tests and benchmarks.
go get -u github.com/gkampitakis/go-tiny-lru
Then you can use it in your code
import "github.com/gkampitakis/go-tiny-lru"
LRU.New(10,1000)
// First parameter is the max items that LRU can store
// and the second is the ttl number.
//You can set them both to zero for no max capacity and no ttl.
Creates a new LRU instance.
Parameters: max int
,ttl int64
. max and ttl can be set to zero for
specifying "infinite" capacity and no expiration time.
Returns: error,*LRU
Clears LRU and resets all values.
Parameters: -
Returns: *LRU
Deletes key from LRU if existent.
Parameters: key string
Returns: *LRU
Returns a slice containing all keys in LRU.
Note: the order of insertion is not guaranteed in the output slice as internally LRU uses maps for storing items.
Parameters: -
Returns: []string
Adds a new item in LRU.
Parameters: key string
,value interface{}
Returns: *LRU
Returns the value of a key if existent
Parameters: key string
Returns: interface{} || nil