Open marzack87 opened 4 years ago
I have similar: orm.config.ts:
export const withCache: TypeOrmModuleOptions = {
type: 'postgres',
url: process.env.DATABASE_URL || 'postgres://localhost:5432/api_dev',
synchronize: true,
migrationsRun: true,
logging: true,
cache: {
type: 'redis',
options: {
url: process.env.REDIS_URL || 'redis://localhost:6379',
},
},
autoLoadEntities: true
};
user.controller.ts
@Crud({
model: {
type: User,
},
params: {
id: {
field: 'id',
type: 'number',
primary: true,
},
},
query: {
alwaysPaginate: true,
join: {
profile: {
eager: true
},
},
cache: 20000,
},
})
@ApiTags('users')
@Controller('users')
export class UsersController implements CrudController<User> {
constructor(public service: UsersService) { }
}
I see a connection to redis:
tcp 0 0 172.22.0.2:6379 172.22.0.1:49322 ESTABLISHED
I have made some GET/POST quieries But no KEYS in Redis appears
127.0.0.1:6379> SELECT 0
OK
127.0.0.1:6379> KEYS *
(empty list or set)
@zMotivat0r could you provide some info here please?
same issue here (redis)
builder.getQueryAndParameters() can't be used as identifier
Make sure you have your database up to date using either synchronize or migrations, also consider extending the default duration time (1s)
Hello,
I got the same issue and I think it has never worked. The code is designed to give an array as a key to cache TypeOrm function, the latter needs a string.
2 options are possible the first one would be to concatenate the getQueryAndParameters array or let TypeOrm generates the key.
Hi,
I'm trying to use typeorm cache using the crud decorator:
And simple typeorm configuration:
but no cache is created.
Exploring
typeorm-crud.service.js
code, I've noticed that cache is implemented like this (line 179):but in this way the whole SQL query is used as identifier, but its db field is a VARCHAR(255), and so no record is created inside cache's table