go-create-cache

Create standardized Go Redis-backed cache layers with two-file patterns and randomized TTL handling.

Updated Jan 4, 2026
One-click install
npx skills add https://github.com/cristiano-pacheco/ai-rules --skill go-create-cache
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-create-cache
Source: https://github.com/cristiano-pacheco/ai-rules/tree/main/skills/go-create-cache
Command: npx skills add https://github.com/cristiano-pacheco/ai-rules --skill go-create-cache

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides a standardized approach to building Redis-backed cache layers in Go applications, ensuring consistent interfaces and implementations across internal modules.

Core Features & Use Cases

  • Two-file pattern: Port interface in ports/<cache_name>_cache.go and cache implementation in cache/<cache_name>_cache.go.
  • Deterministic structure: Interface naming, constructor, and key-building helpers follow a strict convention to promote maintainability.
  • TTL with randomness: Includes a randomized TTL to prevent cache stampedes and improve cache efficiency.
  • Fx wiring: Ready-to-wire in module.go using fx.Provide with proper As() binding.
  • Real-world scenarios include user activation caches, session caches, and domain-specific caches backed by Redis.

Quick Start

Implement a new cache by adding a port interface and a cache struct following the required two-file pattern in your module directory.

Frequently Asked Questions about go-create-cache

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

FAQPage Schema
How do I create a standardized Redis cache layer in Go with TTL?

To create a Redis cache layer in Go, use a two-file pattern placing the port interface in ports/ and the implementation in cache/. This enforces deterministic naming, TTL with randomness to prevent stampedes, and Fx wiring for module integration.

What is the two-file pattern for Go Redis cache implementations?

The two-file pattern separates the cache port interface into ports/<cache_name>_cache.go and the implementation into cache/<cache_name>_cache.go. This structure enforces strict key-building conventions and deterministic interfaces across all modules.

How does randomized TTL prevent cache stampedes in Go applications?

Randomized TTL prevents cache stampedes by varying expiration times across cached keys in Go Redis layers. This avoids simultaneous cache misses and database overloads when multiple cached items expire concurrently under heavy traffic.

Can I use Fx dependency injection to wire Redis cache modules in Go?

Yes, the cache layer supports Fx dependency injection through ready-to-wire fx.Provide statements with proper As() binding in module.go. This integrates the Redis cache directly with the project's existing Redis client and modular architecture.

When do I need a dedicated Redis cache layer for my Go modules?

You need a dedicated Redis cache layer for Go modules handling session data, rate limiting, or domain-specific caches. Standardized interfaces and implementations ensure maintainability and consistent cache behavior across internal application modules.