Skip to content

feat: add collection patterns for high-performance data structures#3

Open
daydaygo wants to merge 1 commit intozeromicro:mainfrom
daydaygo:feat/add-collection-patterns
Open

feat: add collection patterns for high-performance data structures#3
daydaygo wants to merge 1 commit intozeromicro:mainfrom
daydaygo:feat/add-collection-patterns

Conversation

@daydaygo
Copy link
Copy Markdown

Summary

  • Add references/collection-patterns.md documenting go-zero core/collection package
  • Update SKILL.md with new collection patterns reference

New Content

Data Structure Purpose Complexity
LRU Cache Local hot data caching O(1) get/set
Ring Buffer Fixed-size circular buffer O(1) add
TimingWheel Efficient timer management O(1) add/remove
SafeMap Concurrent-safe map O(1) operations

Details

  • LRU Cache: Local caching with eviction callbacks, usage in ServiceContext
  • Ring Buffer: Log buffering, fixed-window statistics
  • TimingWheel: Request timeouts, delayed tasks, heartbeat detection
  • SafeMap: Service registry, config store, memory management best practices

Each section includes:

  • ✅ Correct usage patterns
  • ❌ Common mistakes to avoid
  • Complete code examples
  • Performance considerations

Related

Addresses content from go-zero collection article

Add comprehensive documentation for go-zero core/collection package:
- LRU Cache: local hot data caching with O(1) operations
- Ring Buffer: fixed-size circular buffer for logs/metrics
- TimingWheel: efficient timer management for timeouts/delays
- SafeMap: concurrent-safe map with memory management tips

Includes usage examples, best practices, and common pitfalls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant