lru implementation in golang
- First init a cache with size
c, er := lru.New(<size>)
c, the cache instance er, if cache creation had any error
- Add to cache
wasThereAnyEviction = c.Add(<any_string_value>)
wasThereAnyEviction, (bool) that tells whether there was an eviction for adding cache
- Query to cache
val, ok = c.Query(<any_string_value>)
val, the value against the query (defaults to empty string "", if in case query not found) ok, if query has corresponding value or not
- main.go -> the lru cache
- main_test.go -> the test files
- go 1.14+
- make 4.1+
- inotifywait 3.14
All modules has their *_test
files as UT.
run tests with
make test
- complete testing with full coverage
- use mutex locks for concurrency protection
- use separate key value for storing into in cache
- use persistent storage
- more to discuss