|
2 | 2 |
|
3 | 3 | All notable changes to this project will be documented in this file. |
4 | 4 |
|
5 | | -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
6 | | -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
7 | | - |
8 | 5 | ## [1.0.0] - 2025-01-27 |
9 | 6 |
|
10 | | -### 🎉 Initial Release |
11 | | - |
12 | | -The first stable release of obcache-go, a high-performance, feature-rich caching library for Go. |
13 | | - |
14 | | -### ✨ Core Features |
15 | | - |
16 | | -#### Cache Operations |
17 | | -- **Thread-safe operations** with optimized locking |
18 | | -- **Generic function wrapping** with type safety |
19 | | -- **TTL support** with configurable cleanup intervals |
20 | | -- **Comprehensive statistics** with hit/miss tracking |
21 | | -- **Multiple backends**: Memory and Redis support |
22 | | - |
23 | | -#### Eviction Strategies |
24 | | -- **LRU (Least Recently Used)** - Default strategy, optimal for most use cases |
25 | | -- **LFU (Least Frequently Used)** - Best for frequency-based access patterns |
26 | | -- **FIFO (First In, First Out)** - Simple time-based eviction |
27 | | -- **Pluggable architecture** for custom eviction strategies |
28 | | - |
29 | | -#### Function Wrapping |
30 | | -- **Automatic caching** of function results with `obcache.Wrap()` |
31 | | -- **Type-safe generics** support for all Go function signatures |
32 | | -- **Singleflight pattern** prevents duplicate concurrent function calls |
33 | | -- **Configurable error caching** with separate TTL settings |
34 | | -- **Custom key generation** functions |
35 | | - |
36 | | -#### Advanced Features |
37 | | -- **Hook system** with priority and conditional execution |
38 | | -- **Context-aware operations** with metadata support |
39 | | -- **Compression support** (gzip, lz4) with configurable thresholds |
40 | | -- **Metrics integration** (Prometheus, OpenTelemetry) |
41 | | -- **Debug HTTP handler** for cache inspection and monitoring |
42 | | - |
43 | | -### 📦 Backend Support |
44 | | - |
45 | | -#### Memory Backend |
46 | | -- **High performance** with nanosecond access times |
47 | | -- **Configurable capacity** with automatic eviction |
48 | | -- **Multiple eviction strategies** (LRU/LFU/FIFO) |
49 | | -- **TTL cleanup** with configurable intervals |
50 | | - |
51 | | -#### Redis Backend |
52 | | -- **Distributed caching** across multiple application instances |
53 | | -- **Persistent storage** with Redis durability guarantees |
54 | | -- **Custom Redis client** support for advanced configurations |
55 | | -- **Key prefixing** to avoid conflicts in shared Redis instances |
56 | | - |
57 | | -### 🎣 Hook System |
58 | | - |
59 | | -#### Basic Hooks |
60 | | -- `OnHit` - Cache hit events |
61 | | -- `OnMiss` - Cache miss events |
62 | | -- `OnEvict` - Entry eviction events |
63 | | -- `OnInvalidate` - Manual invalidation events |
64 | | - |
65 | | -#### Advanced Hooks |
66 | | -- **Context-aware hooks** with function arguments |
67 | | -- **Priority-based execution** (High/Medium/Low) |
68 | | -- **Conditional execution** with custom conditions |
69 | | -- **Built-in conditions**: Key prefix, context values, logical combinations |
70 | | - |
71 | | -### 📊 Statistics & Monitoring |
72 | | - |
73 | | -#### Built-in Metrics |
74 | | -- Hit/miss counts and rates |
75 | | -- Eviction counts by reason |
76 | | -- Key count and capacity utilization |
77 | | -- Operation timing and performance |
78 | | - |
79 | | -#### Extensible Monitoring |
80 | | -- **Prometheus integration** with standard metrics |
81 | | -- **OpenTelemetry support** for distributed tracing |
82 | | -- **Custom exporters** for third-party monitoring systems |
83 | | -- **Real-time dashboard** via debug HTTP handler |
84 | | - |
85 | | -### 🔧 Configuration |
86 | | - |
87 | | -#### Fluent Configuration API |
88 | | -```go |
89 | | -config := obcache.NewDefaultConfig(). |
90 | | - WithMaxEntries(10000). |
91 | | - WithLFUEviction(). |
92 | | - WithDefaultTTL(time.Hour). |
93 | | - WithCompress("gzip"). |
94 | | - WithMetricsExporter(prometheusExporter) |
95 | | -``` |
96 | | - |
97 | | -#### Environment-based Configuration |
98 | | -- Redis connection from environment variables |
99 | | -- Configurable defaults for different environments |
100 | | -- Production-ready configuration templates |
101 | | - |
102 | | -### 📚 Documentation & Examples |
103 | | - |
104 | | -#### Comprehensive Documentation |
105 | | -- [**Getting Started Guide**](docs/getting-started.md) |
106 | | -- [**Eviction Strategies Guide**](docs/eviction-strategies.md) |
107 | | -- [**Backend Switching Guide**](docs/backend-switching.md) |
108 | | -- [**Migration Guide**](docs/migration-guide.md) from popular libraries |
109 | | -- [**Complete API Reference**](docs/api-reference.md) |
110 | | - |
111 | | -#### Real-world Examples |
112 | | -- [**Basic Usage**](examples/basic/) - Simple cache operations |
113 | | -- [**Gin Web Server**](examples/gin-web-server/) - REST API caching |
114 | | -- [**Echo Web Server**](examples/echo-web-server/) - Multi-layer caching |
115 | | -- [**Batch Processing**](examples/batch-processing/) - High-throughput scenarios |
116 | | -- [**Redis Integration**](examples/redis-cache/) - Distributed caching |
117 | | -- [**Metrics & Monitoring**](examples/prometheus/) - Observability setup |
118 | | - |
119 | | -### 🚀 Performance |
120 | | - |
121 | | -#### Benchmark Results |
122 | | -``` |
123 | | -BenchmarkCacheGet-8 20000000 95.2 ns/op 16 B/op 1 allocs/op |
124 | | -BenchmarkCacheSet-8 10000000 148.2 ns/op 64 B/op 2 allocs/op |
125 | | -BenchmarkWrappedFunction-8 5000000 245.3 ns/op 96 B/op 3 allocs/op |
126 | | -BenchmarkConcurrentAccess-8 50000000 45.1 ns/op 8 B/op 0 allocs/op |
127 | | -``` |
128 | | - |
129 | | -#### Performance Features |
130 | | -- **Lock-free reads** where possible |
131 | | -- **Batch operations** for bulk updates |
132 | | -- **Memory-efficient storage** with object pooling |
133 | | -- **Optimized serialization** for complex data types |
134 | | - |
135 | | -### 🧪 Testing & Quality |
136 | | - |
137 | | -#### Comprehensive Test Suite |
138 | | -- **Unit tests** with >95% coverage |
139 | | -- **Integration tests** for all backends |
140 | | -- **Stress tests** for high-concurrency scenarios |
141 | | -- **Fuzz testing** for edge cases and input validation |
142 | | -- **Benchmark tests** for performance regression detection |
143 | | - |
144 | | -#### Code Quality |
145 | | -- **golangci-lint** with strict rules |
146 | | -- **Go vet** and race condition detection |
147 | | -- **Continuous integration** with GitHub Actions |
148 | | -- **Semantic versioning** for stable releases |
149 | | - |
150 | | -### 🛠 Developer Experience |
151 | | - |
152 | | -#### Modern Go Features |
153 | | -- **Generics support** (Go 1.18+) for type safety |
154 | | -- **Context integration** throughout the API |
155 | | -- **Error wrapping** with detailed error messages |
156 | | -- **Resource management** with proper cleanup |
| 7 | +### Initial Release |
157 | 8 |
|
158 | | -#### IDE Integration |
159 | | -- **Complete godoc** documentation |
160 | | -- **Type hints** and autocompletion |
161 | | -- **Example code** in documentation |
162 | | -- **Comprehensive error messages** |
| 9 | +High-performance, thread-safe caching library for Go. |
163 | 10 |
|
164 | | -### 📋 Migration Support |
165 | | - |
166 | | -#### Supported Libraries |
167 | | -- Migration from `patrickmn/go-cache` |
168 | | -- Migration from `go-redis/cache` |
169 | | -- Migration from `allegro/bigcache` |
170 | | -- Migration from `hashicorp/golang-lru` |
171 | | - |
172 | | -#### Migration Tools |
173 | | -- **API compatibility layers** for common patterns |
174 | | -- **Performance comparison** benchmarks |
175 | | -- **Feature mapping** guides |
176 | | -- **Gradual migration** strategies |
177 | | - |
178 | | ---- |
179 | | - |
180 | | -## Development History |
181 | | - |
182 | | -This changelog represents the culmination of extensive development phases: |
183 | | - |
184 | | -### Phase 1: MVP (Core Memory Cache & API) |
185 | | -- Basic cache operations (Get/Set/Invalidate) |
186 | | -- Memory backend with LRU eviction |
187 | | -- TTL support with cleanup |
| 11 | +**Core Features:** |
| 12 | +- Function wrapping with `obcache.Wrap()` |
| 13 | +- TTL support with automatic cleanup |
| 14 | +- LRU/LFU/FIFO eviction strategies |
188 | 15 | - Thread-safe operations |
189 | | -- Function wrapping foundation |
190 | | - |
191 | | -### Phase 2: Observability & Debugging |
192 | | -- Comprehensive hook system |
193 | | -- Statistics and metrics |
194 | | -- Debug HTTP handler |
195 | | -- Logging integration |
196 | | -- Performance monitoring |
197 | | - |
198 | | -### Phase 3: Backend Extensibility |
199 | | -- Redis backend implementation |
200 | | -- Backend abstraction layer |
201 | | -- Configuration system |
202 | | -- Environment-based setup |
203 | | -- Connection management |
204 | | - |
205 | | -### Phase 4: Advanced Features |
206 | | -- **Configurable error caching** for robust function wrapping |
207 | | -- **Pluggable eviction strategies** (LFU, FIFO, custom) |
208 | | -- **Enhanced hooks** with priority and conditions |
209 | | -- **Compression support** for large values |
210 | | -- **Metrics integration** with popular systems |
211 | | - |
212 | | -### Phase 5: Production Hardening |
213 | | -- **Stress testing** and fuzz testing |
214 | | -- **Real-world examples** for common use cases |
215 | | -- **Migration guides** from popular libraries |
216 | | -- **Performance optimization** and benchmarking |
217 | | -- **Documentation completeness** |
218 | | - |
219 | | ---- |
220 | | - |
221 | | -## Versioning Strategy |
222 | | - |
223 | | -obcache-go follows [Semantic Versioning](https://semver.org/): |
224 | | - |
225 | | -- **MAJOR** version when making incompatible API changes |
226 | | -- **MINOR** version when adding functionality in a backwards compatible manner |
227 | | -- **PATCH** version when making backwards compatible bug fixes |
228 | | - |
229 | | -## Compatibility Promise |
230 | | - |
231 | | -- **Go Version**: Supports Go 1.18+ (required for generics) |
232 | | -- **API Stability**: Public API is stable and follows semantic versioning |
233 | | -- **Backend Compatibility**: Redis 6.0+ recommended, 5.0+ supported |
234 | | -- **Platform Support**: Linux, macOS, Windows (wherever Go runs) |
235 | | - |
236 | | -## Getting Started |
237 | | - |
238 | | -```go |
239 | | -go get github.com/vnykmshr/obcache-go |
240 | | -``` |
241 | | - |
242 | | -```go |
243 | | -package main |
244 | | - |
245 | | -import ( |
246 | | - "fmt" |
247 | | - "time" |
248 | | - "github.com/vnykmshr/obcache-go/pkg/obcache" |
249 | | -) |
250 | | - |
251 | | -func main() { |
252 | | - // Create cache |
253 | | - cache, err := obcache.New(obcache.NewDefaultConfig()) |
254 | | - if err != nil { |
255 | | - panic(err) |
256 | | - } |
257 | | - defer cache.Close() |
258 | | - |
259 | | - // Basic operations |
260 | | - cache.Set("key", "value", time.Hour) |
261 | | - |
262 | | - if value, found := cache.Get("key"); found { |
263 | | - fmt.Printf("Found: %s\n", value) |
264 | | - } |
265 | | - |
266 | | - // Function wrapping |
267 | | - expensiveFunc := func(n int) int { |
268 | | - time.Sleep(100 * time.Millisecond) |
269 | | - return n * 2 |
270 | | - } |
271 | | - |
272 | | - cachedFunc := obcache.Wrap(cache, expensiveFunc) |
273 | | - result := cachedFunc(42) // Cached automatically! |
274 | | - |
275 | | - fmt.Printf("Result: %d\n", result) |
276 | | -} |
277 | | -``` |
278 | | - |
279 | | -## Contributing |
280 | | - |
281 | | -We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details. |
282 | | - |
283 | | -## License |
284 | | - |
285 | | -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
286 | | - |
287 | | -## Acknowledgments |
288 | | - |
289 | | -- Inspired by battle-tested libraries like `go-cache`, `bigcache`, and `golang-lru` |
290 | | -- Built with modern Go features and best practices |
291 | | -- Designed for production use at scale |
| 16 | +- Redis backend support |
| 17 | +- Compression (gzip/deflate) |
| 18 | +- Statistics and monitoring hooks |
292 | 19 |
|
293 | | ---- |
| 20 | +**API:** |
| 21 | +- `cache.Get(key)` / `cache.Set(key, value, ttl)` |
| 22 | +- `obcache.Wrap(cache, function, options...)` |
| 23 | +- Memory and Redis backends |
| 24 | +- Prometheus/OpenTelemetry metrics |
294 | 25 |
|
295 | | -**Full Changelog**: https://github.com/vnykmshr/obcache-go/commits/v1.0.0 |
| 26 | +See [README.md](README.md) for usage examples. |
0 commit comments