Redis Storage
Redis is the recommended choice for high-availability, distributed systems. It provides shared storage and atomic locking across multiple server nodes.
import "github.com/fco-gt/gopotency/storage/redis"
// Connect to a local or remote Redis instancestore, err := redis.NewRedisStorage(ctx, "localhost:6379", "password")Features
Section titled “Features”- Distributed Locking: Natively handles concurrency across multiple server instances.
- TTL Support: Automatically expires records based on your configuration.
- Horizontal Scaling: Allows your API to scale while maintaining idempotency state.
Best Practices
Section titled “Best Practices”- Connection Pooling:
NewRedisStorageuses the officialgo-redisclient, which handles connection pooling. - Network Latency: Place your Redis instance close to your API nodes to minimize the overhead of idempotency checks.