license and readme
This commit is contained in:
parent
ac292ced9b
commit
206d3112db
11
LICENSE.md
Normal file
11
LICENSE.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Sharkk Open License
|
||||
|
||||
Copyright © 2025 Sharkk, sharkk.net
|
||||
|
||||
You can do whatever you want with this software - use, copy, change, share, sell, give away, or distribute it. Just include this license and copyright notice when you share it. All copyright notices within the source code must remain intact.
|
||||
|
||||
No public attribution is required beyond maintaining these notices.
|
||||
|
||||
This software comes with no warranties or guarantees. The authors aren't responsible for any problems that might happen when you use it.
|
||||
|
||||
You can also treat this as public domain if you prefer - no restrictions at all on how you use, modify, or share it.
|
53
README.md
53
README.md
@ -1,3 +1,54 @@
|
||||
# LRU
|
||||
|
||||
Simple, fast, efficient LRU cache.
|
||||
Thread-safe LRU cache implementation with O(1) ops.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
go get git.sharkk.net/Go/LRU
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
import "git.sharkk.net/Go/LRU"
|
||||
|
||||
// Create cache with capacity 100
|
||||
cache := lru.NewLRUCache(100)
|
||||
|
||||
// Add items
|
||||
cache.Put("key", "value")
|
||||
cache.Put(123, struct{Name string}{"example"})
|
||||
|
||||
// Get items
|
||||
value, exists := cache.Get("key")
|
||||
if exists {
|
||||
fmt.Println(value) // "value"
|
||||
}
|
||||
|
||||
// Check size
|
||||
fmt.Println(cache.Len()) // 2
|
||||
|
||||
// Clear cache
|
||||
cache.Clear()
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- **O(1) operations** for Get and Put
|
||||
- **Thread-safe** using sync.RWMutex
|
||||
- **Generic** - accepts any key/value types
|
||||
- **Automatic eviction** when capacity exceeded
|
||||
- **Zero allocations** for cache hits
|
||||
|
||||
## Performance
|
||||
|
||||
```
|
||||
cpu: 13th Gen Intel(R) Core(TM) i7-1370P
|
||||
BenchmarkPut-20 26019799 45.93 ns/op 13 B/op 1 allocs/op
|
||||
BenchmarkGet-20 34455165 35.16 ns/op 0 B/op 0 allocs/op
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[Sharkk Open License](LICENSE.md)
|
||||
|
Loading…
x
Reference in New Issue
Block a user