-
-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
Not sure if this is a bug or expected behaviour
From my testing with both redis adapters it seems that ioredis-adapter always use string key type regardless of hashKey decorator
Simple example to reproduce
type User = {
name: string;
id: number;
};
export class Users {
static userCacheKey = (args: any) => args[0];
@Cacheable({
cacheKey: 'users'
})
listUsers(): Promise<User[]> {
return Promise.resolve([
{ name: 'John Doe', id: 100 },
{ name: 'Jane Smith', id: 200 }
]);
}
@Cacheable({
cacheKey: Users.userCacheKey,
hashKey: 'user',
})
getUser(id: number): Promise<User> {
return this.listUsers().then((users) => users.find((u) => u.id === id)!);
}
}
When monitoring with redis adapter enabled with above for
await Users.getUser(100);
"HGETALL" "user:100"
"GET" "users"
"SET" "users" "[{\"name\":\"John Doe\",\"id\":100},{\"name\":\"Jane Smith\",\"id\":200}]"
"HSET" "user:100" "name" "\"John Doe\"" "id" "100"
when monitoring with ioredis adapter enabled
"get" "user:100"
"get" "users"
"set" "users" "[{\"name\":\"John Doe\",\"id\":100},{\"name\":\"Jane Smith\",\"id\":200}]"
"set" "user:100" "{\"name\":\"John Doe\",\"id\":100}"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels