Documentation
¶
Index ¶
- func CloseAll() error
- func CloseConnection(name string) error
- func GetClient(name string) (*redis.Client, bool)
- func GetConnection(name string, cfg *config.RedisConfig) (*redis.Client, error)
- func ListConnections() []string
- func Ready(name string) bool
- type IdempotencyRecord
- type IdempotencyStore
- type RedisIdempotencyStore
- func (s *RedisIdempotencyStore) Delete(ctx context.Context, key string) error
- func (s *RedisIdempotencyStore) Exists(ctx context.Context, key string) (bool, error)
- func (s *RedisIdempotencyStore) Get(ctx context.Context, key string) (*IdempotencyRecord, error)
- func (s *RedisIdempotencyStore) Store(ctx context.Context, key string, record *IdempotencyRecord, ttl time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseConnection ¶
CloseConnection safely closes and removes a specific connection
func GetConnection ¶
GetConnection returns a cached Redis connection or creates a new one
Types ¶
type IdempotencyRecord ¶
type IdempotencyRecord struct {
Key string `json:"key"`
Response []byte `json:"response"`
ContentType string `json:"content_type"`
StatusCode int `json:"status_code"`
CreatedAt time.Time `json:"created_at"`
}
IdempotencyRecord stores the cached response for an idempotent request
type IdempotencyStore ¶
type IdempotencyStore interface {
// Get retrieves a cached response by idempotency key
// Returns nil, nil if key does not exist
Get(ctx context.Context, key string) (*IdempotencyRecord, error)
// Store saves a response with the given idempotency key and TTL
Store(ctx context.Context, key string, record *IdempotencyRecord, ttl time.Duration) error
// Exists checks if an idempotency key exists (for quick checks)
Exists(ctx context.Context, key string) (bool, error)
// Delete removes an idempotency record
Delete(ctx context.Context, key string) error
}
IdempotencyStore interface for storing/retrieving idempotency records
type RedisIdempotencyStore ¶
type RedisIdempotencyStore struct {
// contains filtered or unexported fields
}
RedisIdempotencyStore implements IdempotencyStore using Redis
func NewRedisIdempotencyStore ¶
func NewRedisIdempotencyStore(client *redis.Client, prefix string) *RedisIdempotencyStore
NewRedisIdempotencyStore creates a new Redis-backed idempotency store prefix: namespace for keys (e.g., "idempotency" -> "idempotency:key")
func (*RedisIdempotencyStore) Delete ¶
func (s *RedisIdempotencyStore) Delete(ctx context.Context, key string) error
Delete removes an idempotency record
func (*RedisIdempotencyStore) Exists ¶
Exists checks if an idempotency key exists (for quick checks without fetching data)
func (*RedisIdempotencyStore) Get ¶
func (s *RedisIdempotencyStore) Get(ctx context.Context, key string) (*IdempotencyRecord, error)
Get retrieves a cached response by idempotency key Returns nil, nil if key does not exist (not an error condition)
func (*RedisIdempotencyStore) Store ¶
func (s *RedisIdempotencyStore) Store(ctx context.Context, key string, record *IdempotencyRecord, ttl time.Duration) error
Store saves a response with the given idempotency key and TTL