type-cacheable
type-cacheable copied to clipboard
[BUG] CacheClear not working on Azure Redis
Describe the bug type-cacheable CacheClear failure on method updateUserDetails due to client error: Cannot read property 'redis_version' of undefined when using @CacheClear
To Reproduce Steps to reproduce the behavior: When using the packages :
- "@type-cacheable/core": "^9.1.0"
- "@type-cacheable/redis-adapter": "^9.1.0 ,
- "ioredis": "^4.19.4"
- "redis": "^3.0.2",
and connecting to Azure Redis Cache, the following error appears (when debugging is enabled):
type-cacheable CacheClear failure on method ...... due to client error: Cannot read property 'redis_version' of undefined and the clearing the key is not working
Expected behavior The cachekey should be cleared
Additional context Analysis learns that this line of code in the index.js of the adapter introduces the exception
if (compareVersions(this.redisClient.**server_info**.redis_version, REDIS_VERSION_UNLINK_INTRODUCED) >= 0) {
this.redisClient.unlink(keyOrKeys, RedisAdapter.responseCallback(resolve, reject));
}
Debugger learns that in 'our' situation the property is not server_info but serverInfo , when replacing this property, everything works as expected again
Hi @christianvanr, I am not sure what is happening here: https://github.com/NodeRedis/node-redis/blob/master/README.md#clientserver_info
According to the redis
package and its corresponding types, this information comes through on client.server_info
. Looking through the source of the library, I see the same. Do you have any more information on what could be causing this discrepancy?
By changeing the adapter from @type-cacheable/redis-adapter to '@type-cacheable/ioredis-adapter' it is working (i didn't dive into the code, but maybe the check is not implemented there)/ If you still intrested in it : we are using : "redis": "^3.0.2", and "ioredis": "^4.19.4", (both are needed because we are using also other libraries, which are using redis)
This should be working in the latest version of the redis-adapter.