Documentation
¶
Index ¶
Constants ¶
View Source
const ( // HeaderKey is the standard idempotency key header HeaderKey = "Idempotency-Key" // DefaultTTL is the default cache duration for idempotent responses (24 hours) DefaultTTL = 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory implementation of Store with LRU eviction
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore creates a new in-memory idempotency store with a maximum of 10,000 entries
func NewMemoryStoreWithSize ¶
func NewMemoryStoreWithSize(maxSize int) *MemoryStore
NewMemoryStoreWithSize creates a new in-memory idempotency store with custom max size
func (*MemoryStore) Delete ¶
func (s *MemoryStore) Delete(ctx context.Context, key string) error
Delete removes a cached response
func (*MemoryStore) Set ¶
func (s *MemoryStore) Set(ctx context.Context, key string, response *Response, ttl time.Duration) error
Set stores a response for the given key with TTL
func (*MemoryStore) Stop ¶
func (s *MemoryStore) Stop()
Stop gracefully shuts down the cleanup goroutine
type Store ¶
type Store interface {
// Get retrieves a cached response for the given key
Get(ctx context.Context, key string) (*Response, bool)
// Set stores a response for the given key with TTL
Set(ctx context.Context, key string, response *Response, ttl time.Duration) error
// Delete removes a cached response
Delete(ctx context.Context, key string) error
}
Store manages idempotency keys and cached responses
Click to show internal directories.
Click to hide internal directories.