New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@tc-libs/app-cache

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tc-libs/app-cache

Astrazione cache per NestJS basata su `@nestjs/cache-manager`. Supporta due modalita:

latest
npmnpm
Version
3.9.0
Version published
Maintainers
1
Created
Source

@tc-libs/app-cache

Astrazione cache per NestJS basata su @nestjs/cache-manager. Supporta due modalita:

  • cache in-memory quando enabled e false
  • cache Redis quando enabled e true

Il package viene usato soprattutto dai repository Mongo del monorepo per cacheare query e count.

Registrazione

AppCacheModule.register(
  true,
  {
    enabled: true,
    ttl: 60,
    server: {
      host: '127.0.0.1',
      port: 6379,
    },
  },
  true,
);

Versione async:

AppCacheModule.registerAsync(
  true,
  {
    imports: [ConfigModule],
    inject: [ConfigService],
    useFactory: async (config: ConfigService) => ({
      enabled: true,
      ttl: 60,
      server: {
        host: config.getOrThrow<string>('REDIS_HOST'),
        port: config.getOrThrow<number>('REDIS_PORT'),
      },
    }),
  },
  true,
);

Servizio esportato

AppCacheService espone i metodi usati dal resto del monorepo:

  • getCachedDataByQuery(functionName, find, options)
  • getCachedDataByKey(key)
  • saveToCache(key, data, options)

Lato repository il pattern tipico e:

const { data, key } = await this.cache.getCachedDataByQuery(
  'findOne',
  find,
  options,
);

if (data) return data;

this.cache.saveToCache(key, result, options);

Note operative

  • La chiave cache viene derivata da functionName, filtro e opzioni tramite hash SHA1 Base64.
  • La cache viene usata solo se il modulo e abilitato e l'operazione passa options.caching.enabled.
  • Se vuoi una chiave custom puoi passare options.caching.key.

Export pubblici

import {
  AppCacheModule,
  AppCacheService,
  ICachingOptions,
} from '@tc-libs/app-cache';

Sviluppo

nx build app-cache
nx test app-cache

FAQs

Package last updated on 01 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts