• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

safe-global / safe-client-gateway / 16111907974

07 Jul 2025 08:28AM UTC coverage: 89.69% (+0.03%) from 89.658%
16111907974

Pull #2630

github

LucieFaire
fix: memory optimization

Signed-off-by: dsh <11198975+LucieFaire@users.noreply.github.com>
Pull Request #2630: feat: Add CsvExport module

3426 of 4188 branches covered (81.81%)

Branch coverage included in aggregate %.

14 of 17 new or added lines in 2 files covered. (82.35%)

37 existing lines in 4 files now uncovered.

11893 of 12892 relevant lines covered (92.25%)

544.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.57
/src/datasources/cache/cache.module.ts
1
import { Global, Module } from '@nestjs/common';
110✔
2
import { createClient } from 'redis';
110✔
3
import { IConfigurationService } from '@/config/configuration.service.interface';
110✔
4
import { CacheService } from '@/datasources/cache/cache.service.interface';
110✔
5
import { RedisCacheService } from '@/datasources/cache/redis.cache.service';
110✔
6
import { CacheReadiness } from '@/domain/interfaces/cache-readiness.interface';
110✔
7
import { ILoggingService, LoggingService } from '@/logging/logging.interface';
110✔
8
import { CacheKeyPrefix } from '@/datasources/cache/constants';
110✔
9
import { LogType } from '@/domain/common/entities/log-type.entity';
110✔
10

11
export type RedisClientType = ReturnType<typeof createClient>;
12

13
async function redisClientFactory(
14
  configurationService: IConfigurationService,
15
  loggingService: ILoggingService,
16
): Promise<RedisClientType> {
17
  const redisUser = configurationService.get<string>('redis.user');
4✔
18
  const redisPass = configurationService.get<string>('redis.pass');
4✔
19
  const redisHost = configurationService.getOrThrow<string>('redis.host');
4✔
20
  const redisPort = configurationService.getOrThrow<string>('redis.port');
4✔
21
  const redisDisableOfflineQueue = configurationService.getOrThrow<boolean>(
4✔
22
    'redis.disableOfflineQueue',
23
  );
24
  const client: RedisClientType = createClient({
4✔
25
    socket: {
26
      host: redisHost,
27
      port: Number(redisPort),
28
    },
29
    username: redisUser,
30
    password: redisPass,
31
    disableOfflineQueue: redisDisableOfflineQueue,
32
  });
33
  client.on('error', (err) =>
4✔
UNCOV
34
    loggingService.error({
×
35
      type: LogType.CacheError,
36
      source: 'CacheModule',
37
      event: err.code ?? err.message,
×
38
    }),
39
  );
40
  client.on('reconnecting', () =>
4✔
41
    loggingService.warn({
×
42
      type: LogType.CacheEvent,
43
      source: 'CacheModule',
44
      event: 'Reconnecting to Redis',
45
    }),
46
  );
47
  client.on('end', () =>
4✔
48
    loggingService.warn({
4✔
49
      type: LogType.CacheEvent,
50
      source: 'CacheModule',
51
      event: 'Redis connection closed',
52
    }),
53
  );
54
  await client.connect();
4✔
55
  return client;
4✔
56
}
57

58
@Global()
59
@Module({
60
  providers: [
61
    {
62
      provide: 'RedisClient',
63
      useFactory: redisClientFactory,
64
      inject: [IConfigurationService, LoggingService],
65
    },
66
    { provide: CacheService, useClass: RedisCacheService },
67
    { provide: CacheReadiness, useExisting: CacheService },
68
    { provide: CacheKeyPrefix, useValue: '' },
69
  ],
70
  exports: [CacheService, CacheReadiness],
71
})
72
export class CacheModule {}
110✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc