go-caching

Implement LRU caching and sync.Pool pooling for Go FHIRPath expressions.

2|Updated Feb 14, 2025
One-click install
npx skills add https://github.com/gofhir/validator --skill go-caching
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-caching
Source: https://github.com/gofhir/validator/tree/main/.claude/skills/go-caching
Command: npx skills add https://github.com/gofhir/validator --skill go-caching

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers optimize Go applications by implementing efficient caching and pooling strategies, reducing memory allocations and improving performance for expensive operations.

Core Features & Use Cases

  • Expression Caching: Implements an LRU cache for compiled FHIRPath expressions to speed up repeated evaluations.
  • Object Pooling: Utilizes sync.Pool for reusable objects like collections, minimizing garbage collection overhead.
  • Value Caching: Caches small, immutable integer values to avoid new object creation.
  • Use Case: When evaluating complex FHIRPath expressions frequently against many resources, caching the compiled expression significantly speeds up processing. Similarly, reusing collection objects instead of allocating new ones for every intermediate result reduces memory pressure.

Quick Start

Use the go-caching skill to understand how to implement an LRU cache for compiled FHIRPath expressions in Go.

Frequently Asked Questions about go-caching

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement LRU caching for compiled expressions in Go?

LRU caching for compiled FHIRPath expressions in Go stores previously evaluated results to speed up repeated processing. This prevents redundant compilation overhead and significantly accelerates complex expression evaluations against multiple resources.

What's the best way to reduce memory allocations in Go applications?

Reducing memory allocations in Go is achieved by implementing object pooling with sync.Pool for reusable collections and caching immutable values. These strategies minimize garbage collection overhead and lower memory pressure during intensive computations.

When should I use sync.Pool for object pooling in Golang?

Use sync.Pool for object pooling in Golang when frequently allocating and discarding temporary objects like intermediate collections. Reusing these objects instead of allocating new ones minimizes garbage collection overhead and reduces memory pressure.

How does caching StructureDefinitions improve Go performance?

Caching StructureDefinitions and regular expressions in Go avoids repeated compilation and parsing overhead. By storing these immutable objects in memory, applications speed up repeated computations and reduce allocation overhead during resource processing.

Can I cache small integer values to avoid new object creation in Go?

Caching small, immutable integer values in Go avoids new object creation by reusing existing cached instances. This value caching technique prevents unnecessary memory allocations during frequent numeric operations and processing.

Does object pooling eliminate garbage collection overhead in Go?

Object pooling with sync.Pool reduces garbage collection overhead by reusing allocated objects, but it does not eliminate it entirely. Pooling minimizes memory pressure for intermediate results, yet final object cleanup still requires some garbage collection.