@@ -180,20 +180,41 @@ private Map<String, Object> extractProductInfo(Map<String, Object> item) {
180180
181181 /**
182182 * Redis에서 상품 정보 조회
183- * @param productId 상품 ID
183+ * @param productId 상품 ID (색상 정보 포함 가능: "2711142" 또는 "2711142_블랙")
184184 * @return 상품 정보 Map (없으면 null)
185185 */
186186 public Map <String , Object > getProductInfo (String productId ) {
187187 try {
188+ // 1. 정확한 키로 먼저 시도 (색상 정보가 포함된 경우)
188189 String cacheKey = "product_id:" + productId ;
189190 String productInfoJson = redisTemplate .opsForValue ().get (cacheKey );
190191
191192 if (productInfoJson != null ) {
193+ log .debug ("✅ 정확한 키로 상품 조회 성공: {}" , cacheKey );
192194 return objectMapper .readValue (productInfoJson , Map .class );
193195 }
194196
197+ // 2. 색상 정보가 없는 경우 패턴 매칭으로 찾기
198+ String pattern = "product_id:" + productId + "_*" ;
199+ var keys = redisTemplate .keys (pattern );
200+
201+ if (keys != null && !keys .isEmpty ()) {
202+ // 첫 번째 매칭된 키 사용 (동일 상품의 첫 번째 색상)
203+ String firstKey = keys .iterator ().next ();
204+ productInfoJson = redisTemplate .opsForValue ().get (firstKey );
205+
206+ if (productInfoJson != null ) {
207+ log .info ("✅ 패턴 매칭으로 상품 조회 성공: {} -> {}" , productId , firstKey );
208+ return objectMapper .readValue (productInfoJson , Map .class );
209+ }
210+ }
211+
212+ log .warn ("⚠️ 상품 정보를 찾을 수 없음: productId={}, pattern={}" , productId , pattern );
213+
195214 } catch (JsonProcessingException e ) {
196215 log .error ("❌ 상품 정보 역직렬화 실패: productId={}, error={}" , productId , e .getMessage ());
216+ } catch (Exception e ) {
217+ log .error ("❌ 상품 정보 조회 중 오류: productId={}, error={}" , productId , e .getMessage (), e );
197218 }
198219
199220 return null ;
0 commit comments