From 206d3112db005d57495bac7e18eb84c1fb6f2786 Mon Sep 17 00:00:00 2001 From: Sky Johnson Date: Sat, 24 May 2025 09:33:04 -0500 Subject: [PATCH] license and readme --- LICENSE.md | 11 +++++++++++ README.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..fc299d9 --- /dev/null +++ b/LICENSE.md @@ -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. diff --git a/README.md b/README.md index ceb0873..4221895 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,54 @@ # LRU -Simple, fast, efficient LRU cache. \ No newline at end of file +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)