@@ -160,6 +160,38 @@ export class RedisCache implements ICacheClient {
160160 this . logger . trace ( `${ requestIdPrefix } caching multiple keys via ${ callingMethod } , total keys: ${ entriesLength } ` ) ;
161161 }
162162
163+ /**
164+ * Stores multiple key-value pairs in the cache using pipelining.
165+ *
166+ * @param keyValuePairs - An object where each property is a key and its value is the value to be cached.
167+ * @param callingMethod - The name of the calling method.
168+ * @param {number } [ttl] - The time-to-live (expiration) of the cache item in milliseconds.
169+ * @param requestIdPrefix - Optional request ID prefix for logging.
170+ * @returns {Promise<void> } A Promise that resolves when the values are cached.
171+ */
172+ async pipelineSet (
173+ keyValuePairs : Record < string , any > ,
174+ callingMethod : string ,
175+ ttl ?: number | undefined ,
176+ requestIdPrefix ?: string ,
177+ ) : Promise < void > {
178+ const resolvedTtl = ( ttl ?? this . options . ttl ) / 1000 ; // convert to seconds
179+
180+ const pipeline = this . client . multi ( ) ;
181+
182+ for ( const [ key , value ] of Object . entries ( keyValuePairs ) ) {
183+ const serializedValue = JSON . stringify ( value ) ;
184+ pipeline . setEx ( key , resolvedTtl , serializedValue ) ;
185+ }
186+
187+ // Execute pipeline operation
188+ await pipeline . execAsPipeline ( ) ;
189+
190+ // Log the operation
191+ const entriesLength = Object . keys ( keyValuePairs ) . length ;
192+ this . logger . trace ( `${ requestIdPrefix } caching multiple keys via ${ callingMethod } , total keys: ${ entriesLength } ` ) ;
193+ }
194+
163195 /**
164196 * Deletes a value from the cache.
165197 *
0 commit comments