Description
Issue description
Because of the key name length limit in serverless elasticache, keys generated by typeorm may exceed maximum size.
Expected Behavior
TypeORM should generate shorter cache keys, for example, by creating a digest from the SQL query and parameters.
Relevant code:
typeorm/src/query-builder/SelectQueryBuilder.ts
Line 3814 in a4c9dd8
typeorm/src/query-builder/SelectQueryBuilder.ts
Line 3871 in a4c9dd8
typeorm/src/cache/RedisQueryResultCache.ts
Line 178 in a4c9dd8
Actual Behavior
ReplyError: ERR Request contains a key that is longer than the max key size of 4096 bytes
Steps to reproduce
Connect TypeORM to serverless elasticache using ioredis/cluster cache type:
{
type: "ioredis/cluster",
options: {
startupNodes: [{ host: "...", port: "..." }],
options: {
dnsLookup: (address: string, callback: Function) => callback(null, address),
redisOptions: { tls: {} },
},
},
}
Then run a very long query with multiple joins and parameters that would cause the cache key to exceed the limit.
My Environment
No relevant dependencies to list.
Additional Context
Official documentation mentioning the key name length limit: https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/RedisConfiguration.html#RedisConfiguration.Serverless
Relevant Database Driver(s)
- aurora-mysql
- aurora-postgres
- better-sqlite3
- cockroachdb
- cordova
- expo
- mongodb
- mysql
- nativescript
- oracle
- postgres
- react-native
- sap
- spanner
- sqlite
- sqlite-abstract
- sqljs
- sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.