-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit 5a1c765
feat: Add batchSize option to RedisItemReader for MGET optimization
- Add batchSize parameter to RedisItemReader with default value of 1
- Implement batch fetching using Redis MGET for better performance
- Maintain backward compatibility with existing code
- Add comprehensive test cases for batch reading functionality
This enhancement addresses the N+1 problem by reducing network round-trips
when reading multiple keys from Redis. With batchSize > 1, the reader uses
MGET operations instead of individual GET calls.
Resolves #4941
Signed-off-by: khj68 <junthewise@gmail.com>1 parent 3bcc525 commit 5a1c765
File tree
3 files changed
+182
-5
lines changed- spring-batch-infrastructure/src
- main/java/org/springframework/batch/item/redis
- builder
- test/java/org/springframework/batch/item/redis
3 files changed
+182
-5
lines changedspring-batch-infrastructure/src/main/java/org/springframework/batch/item/redis/RedisItemReader.java
Lines changed: 60 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
18 | + | ||
19 | + | ||
20 | + | ||
21 | + | ||
22 | + | ||
18 | 23 |
| |
19 | 24 |
| |
20 | 25 |
| |
| |||
29 | 34 |
| |
30 | 35 |
| |
31 | 36 |
| |
37 | + | ||
38 | + | ||
39 | + | ||
40 | + | ||
41 | + | ||
42 | + | ||
32 | 43 |
| |
33 | 44 |
| |
34 | 45 |
| |
35 | 46 |
| |
47 | + | ||
36 | 48 |
| |
37 | 49 |
| |
38 | 50 |
| |
| |||
43 | 55 |
| |
44 | 56 |
| |
45 | 57 |
| |
58 | + | ||
59 | + | ||
60 | + | ||
61 | + | ||
46 | 62 |
| |
47 | 63 |
| |
48 | 64 |
| |
65 | + | ||
66 | + | ||
67 | + | ||
68 | + | ||
49 | 69 |
| |
50 | 70 |
| |
71 | + | ||
51 | 72 |
| |
52 | 73 |
| |
74 | + | ||
75 | + | ||
53 | 76 |
| |
54 | 77 |
| |
55 | 78 |
| |
| |||
59 | 82 |
| |
60 | 83 |
| |
61 | 84 |
| |
62 | - | ||
63 | - | ||
64 | - | ||
85 | + | ||
86 | + | ||
87 | + | ||
65 | 88 |
| |
66 | - | ||
89 | + | ||
90 | + | ||
91 | + | ||
92 | + | ||
93 | + | ||
94 | + | ||
95 | + | ||
96 | + | ||
97 | + | ||
98 | + | ||
99 | + | ||
100 | + | ||
101 | + | ||
102 | + | ||
103 | + | ||
104 | + | ||
105 | + | ||
106 | + | ||
107 | + | ||
67 | 108 |
| |
68 | 109 |
| |
110 | + | ||
111 | + | ||
112 | + | ||
113 | + | ||
114 | + | ||
115 | + | ||
116 | + | ||
117 | + | ||
118 | + | ||
119 | + | ||
120 | + | ||
121 | + | ||
122 | + | ||
123 | + | ||
124 | + | ||
69 | 125 |
| |
70 | 126 |
| |
71 | 127 |
| |
|
Lines changed: 17 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
26 | + | ||
26 | 27 |
| |
27 | 28 |
| |
28 | 29 |
| |
| |||
33 | 34 |
| |
34 | 35 |
| |
35 | 36 |
| |
37 | + | ||
38 | + | ||
36 | 39 |
| |
37 | 40 |
| |
38 | 41 |
| |
| |||
53 | 56 |
| |
54 | 57 |
| |
55 | 58 |
| |
59 | + | ||
60 | + | ||
61 | + | ||
62 | + | ||
63 | + | ||
64 | + | ||
65 | + | ||
66 | + | ||
67 | + | ||
68 | + | ||
69 | + | ||
70 | + | ||
71 | + | ||
56 | 72 |
| |
57 | 73 |
| |
58 | 74 |
| |
59 | 75 |
| |
60 | 76 |
| |
61 | - | ||
77 | + | ||
62 | 78 |
| |
63 | 79 |
| |
64 | 80 |
|
Lines changed: 105 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
15 | 15 |
| |
16 | 16 |
| |
17 | 17 |
| |
18 | + | ||
19 | + | ||
20 | + | ||
21 | + | ||
18 | 22 |
| |
19 | 23 |
| |
20 | 24 |
| |
| |||
62 | 66 |
| |
63 | 67 |
| |
64 | 68 |
| |
69 | + | ||
70 | + | ||
71 | + | ||
72 | + | ||
73 | + | ||
74 | + | ||
75 | + | ||
76 | + | ||
77 | + | ||
78 | + | ||
79 | + | ||
80 | + | ||
81 | + | ||
82 | + | ||
83 | + | ||
84 | + | ||
85 | + | ||
86 | + | ||
87 | + | ||
88 | + | ||
89 | + | ||
90 | + | ||
91 | + | ||
92 | + | ||
93 | + | ||
94 | + | ||
95 | + | ||
96 | + | ||
97 | + | ||
98 | + | ||
99 | + | ||
100 | + | ||
101 | + | ||
102 | + | ||
103 | + | ||
104 | + | ||
105 | + | ||
106 | + | ||
107 | + | ||
108 | + | ||
109 | + | ||
110 | + | ||
111 | + | ||
112 | + | ||
113 | + | ||
114 | + | ||
115 | + | ||
116 | + | ||
117 | + | ||
118 | + | ||
119 | + | ||
120 | + | ||
121 | + | ||
122 | + | ||
123 | + | ||
124 | + | ||
125 | + | ||
126 | + | ||
127 | + | ||
128 | + | ||
129 | + | ||
130 | + | ||
131 | + | ||
132 | + | ||
133 | + | ||
134 | + | ||
135 | + | ||
136 | + | ||
137 | + | ||
138 | + | ||
139 | + | ||
140 | + | ||
141 | + | ||
142 | + | ||
143 | + | ||
144 | + | ||
145 | + | ||
146 | + | ||
147 | + | ||
148 | + | ||
149 | + | ||
150 | + | ||
151 | + | ||
152 | + | ||
153 | + | ||
154 | + | ||
155 | + | ||
156 | + | ||
157 | + | ||
158 | + | ||
159 | + | ||
160 | + | ||
161 | + | ||
162 | + | ||
163 | + | ||
164 | + | ||
165 | + | ||
166 | + | ||
167 | + | ||
168 | + | ||
169 | + | ||
65 | 170 |
|
0 commit comments