https://github.com/codeofnode/lru-go
LRU caching in golang
https://github.com/codeofnode/lru-go
Last synced: 11 months ago
JSON representation
LRU caching in golang
- Host: GitHub
- URL: https://github.com/codeofnode/lru-go
- Owner: codeofnode
- License: apache-2.0
- Created: 2020-05-16T17:36:30.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-16T17:38:14.000Z (almost 6 years ago)
- Last Synced: 2025-01-28T16:17:44.729Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lru-go
lru implementation in golang
# API docs
1. First init a cache with size
```
c, er := lru.New()
```
c, the cache instance
er, if cache creation had any error
2. Add to cache
```
wasThereAnyEviction = c.Add()
```
wasThereAnyEviction, (bool) that tells whether there was an eviction for adding cache
3. Query to cache
```
val, ok = c.Query()
```
val, the value against the query (defaults to empty string "", if in case query not found)
ok, if query has corresponding value or not
# dir structure
* main.go -> the lru cache
* main_test.go -> the test files
# dependencies
* go 1.14+
## dev dependencies
* make 4.1+
* inotifywait 3.14
# testing
All modules has their `*_test` files as UT.
run tests with
```
make test
```
# TODO
* 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