This directory contains practical examples demonstrating how to use the HOT cache library in various scenarios.
Choose an example based on your needs:
- Simple LRU - Basic cache operations and LRU eviction
- TTL Cache - Time-based expiration with jitter and background cleanup
- Batch Operations - Performance optimization with batch operations
- Concurrency - Thread safety and concurrent access patterns
- Observability - Prometheus metrics and monitoring
- Database Integration - PostgreSQL integration with cache-aside pattern
- Web Application - HTTP server with RESTful API and caching
-
Clone the repository:
git clone https://github.com/samber/hot.git cd hot/examples -
Run a basic example:
cd basic/simple-lru go run simple.go -
Explore advanced features:
cd ../web go run web-server.go
Feel free to add new examples or improve existing ones. Each example should:
- Be concise and readable in a few seconds
- Include a comprehensive README
- Demonstrate practical use cases
- Follow Go best practices