feat: implement HashArray utility and refactor product key generation for Redis
This commit is contained in:
@@ -22,6 +22,10 @@ type apiRepository struct {
|
||||
marketplaceRepository marketplace.Repository
|
||||
}
|
||||
|
||||
func GetProductsKey(identifier string) string {
|
||||
return fmt.Sprintf("ozon:products:%s", identifier)
|
||||
}
|
||||
|
||||
func NewAPIRepository(marketplaceRepository marketplace.Repository) Repository {
|
||||
return &apiRepository{
|
||||
marketplaceRepository: marketplaceRepository,
|
||||
@@ -136,7 +140,7 @@ func (a *apiRepository) StreamAllProductsCache(ctx context.Context, marketplaceI
|
||||
errChan <- fmt.Errorf("getting marketplace identifier: %w", err)
|
||||
return
|
||||
}
|
||||
key := fmt.Sprintf("ozon:products:%s", identifier)
|
||||
key := GetProductsKey(identifier)
|
||||
var cachedMessage pb.GetListOfProductsResponse
|
||||
err = redis.ReadProtoMessage(ctx, key, &cachedMessage)
|
||||
if err == nil && len(cachedMessage.Products) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user