feat: implement HashArray utility and refactor product key generation for Redis
This commit is contained in:
@@ -39,6 +39,10 @@ func NewAPIRepository(marketplaceRepository marketplace.Repository) Repository {
|
||||
}
|
||||
}
|
||||
|
||||
func GetProductKey(identifier string) string {
|
||||
return fmt.Sprintf("ym:products:%s", identifier)
|
||||
}
|
||||
|
||||
// getBusinessID retrieves the business ID for a given marketplace by looking up the campaign
|
||||
func (r *apiRepository) getBusinessID(ctx context.Context, mp *marketplace.Marketplace) (int64, error) {
|
||||
if mp.CampaignID == "" {
|
||||
@@ -101,7 +105,7 @@ func (r *apiRepository) GetProducts(ctx context.Context, marketplaceID int, req
|
||||
errChan <- err
|
||||
return
|
||||
}
|
||||
key := fmt.Sprintf("ym:products:%d", businessID)
|
||||
key := GetProductKey(strconv.Itoa(int(businessID)))
|
||||
var cachedMessage pb.GetProductsResponse
|
||||
err = redis.ReadProtoMessage(ctx, key, &cachedMessage)
|
||||
if err == nil && len(cachedMessage.Offers) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user