dukcapil/internal/processor/cached_user_wrapper.go
2025-09-08 12:24:37 +07:00

33 lines
922 B
Go

package processor
import (
"context"
"eslogad-be/internal/contract"
"github.com/google/uuid"
)
// CachedUserWrapper wraps CachedUserProcessor to implement middleware.UserProcessor interface
type CachedUserWrapper struct {
cached *CachedUserProcessor
full *UserProcessorImpl
}
// NewCachedUserWrapper creates a new wrapper
func NewCachedUserWrapper(cached *CachedUserProcessor, full *UserProcessorImpl) *CachedUserWrapper {
return &CachedUserWrapper{
cached: cached,
full: full,
}
}
// GetUserByID uses cached version for fast lookups
func (w *CachedUserWrapper) GetUserByID(ctx context.Context, id uuid.UUID) (*contract.UserResponse, error) {
return w.cached.GetUserByIDCached(ctx, id)
}
// GetUserByIDFull uses full version when all data is needed
func (w *CachedUserWrapper) GetUserByIDFull(ctx context.Context, id uuid.UUID) (*contract.UserResponse, error) {
return w.full.GetUserByID(ctx, id)
}