fix cache service mset (#16327)

pipeline.exec() is a a blocking operation which means if we want to
write a large chunk of data (or many maps in our case) it will block
write operations and impact performances.
We prefer to simply call set multiple times in a promise.all, this is an
acceptable tradeoff
This commit is contained in:
Weiko
2025-12-04 15:49:17 +01:00
committed by GitHub
parent 8ee2efead7
commit d0e75d5948
@@ -67,20 +67,7 @@ export class CacheStorageService {
async mset<T = unknown>(
entries: Array<{ key: string; value: T; ttl?: Milliseconds }>,
): Promise<void> {
if (this.isRedisCache()) {
const pipeline = (this.cache as RedisCache).store.client.multi();
entries.forEach(({ key, value, ttl }) => {
const prefixedKey = this.getKey(key);
pipeline.set(prefixedKey, JSON.stringify(value));
if (ttl) {
pipeline.expire(prefixedKey, Math.floor(ttl / 1000));
}
});
await pipeline.exec();
if (entries.length === 0) {
return;
}