Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

603
Visualizações
Property 'get' does not exist on type 'Cache'. NestJs project

I'm trying to set up Redis caching for my nestjs-graphql project by following this official guide and this tutorial. I'm following the exact steps that are mentioned but I'm getting this error that Property 'get' does not exist on type 'Cache'.

Here's the exact code

import {User} from './user.entity'
import {Resolver, Query, ResolveField, Args, Parent, Mutation} from '@nestjs/graphql'
import { UsersService } from './users.service';
import { PostsService } from '../posts/posts.service';
import { CurrentUser } from 'src/auth/auth.resolver';
import { CACHE_MANAGER, Inject, UseGuards } from '@nestjs/common';
import { GqlAuthGuard } from 'src/auth/graphql-auth.guard';

@Resolver(of => User)
export class UsersResolver {
  constructor(
    @Inject(CACHE_MANAGER) private cacheManager: Cache,
    private usersService: UsersService,
    private postsService: PostsService,
  ) {}

  @Query()
  async getUsers() {
    const value = await this.cacheManager.get('key'); //<--- This is what gives the error
    if(value){                                        // cacheManager doesn't have a get
      console.log({                                   // but both of the mentioned tutorials 
        data: value,                                  // use the same exact property
        loadsFrom: 'redis cache'
      })
    }
    return await this.usersService.findAll();
  }
}
about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Import the Cache used in

@Inject(CACHE_MANAGER) private cacheManager: Cache

from cache-manager

import { Cache } from 'cache-manager';

about 4 years ago · Santiago Trujillo Relatório

0

There isn't much code but one thing that comes to my mind is that Nest couldn't resolve the dependency or it resolved it wrongly. I don't see any import of type Cache look at the docs you have provided (quote below) maybe it will help.

The Cache class is imported from the cache-manager, while CACHE_MANAGER token from the @nestjs/common package.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda