-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
Issue description
The detectRedisVersion function incorrectly detects the Redis version when using versions lower than 4. The "set" function does not exist in version 3.1.2, so the check mistakenly identifies the redisMajorVersion as 5 instead of 3.
Expected Behavior
Ensure that the detectRedisVersion function correctly detects when the Redis version is 3.
Actual Behavior
The detectRedisVersion function incorrectly detects version 3.1.2 as version 5.
`
private detectRedisVersion(): void {
if (this.clientType !== "redis") return
try {
// Detect version by examining the client's method signatures
// This avoids creating test keys in the database
const setMethod = this.client.set
if (setMethod && setMethod.length <= 3) {
// Redis 5+ set method accepts fewer parameters (key, value, options)
this.redisMajorVersion = 5
} else {
// Redis 3/4 set method requires more parameters (key, value, flag, duration, callback)
this.redisMajorVersion = 3
}
} catch {
// Default to Redis 3/4 for maximum compatibility
this.redisMajorVersion = 3
}
}
`
Steps to reproduce
Use Redis version 3.1.2 and try executing a query with caching.
Configuration:
cache: { type: 'redis', options: { host: 'localhost', port: 6379, db: 0 }, duration: 1800000, ignoreErrors: false }
Example:
query.cache('test', 1000);
My Environment
| Dependency | Version |
| Redis version | 3.1.2 |
| TypeORM version | 0.3.27 |
Additional Context
No response
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?
Yes, I have the time, and I know how to start.