I was trying to retrieve cached data (redis) from redis using node js which was set using a .Net core 3.1 application
The code snippet which I was used to set cache is as below
nuget package : Microsoft.Extensions.Caching.StackExchangeRedis v 5.0.0 (Eventhough this is deprecated this is the version which is compatible with .Net core 3.1)
public async Task SetCache(dynamic data, string cacheKey)
{
try
{
if (_redisConfig.EnableCache == true)
{
string cachedDataString = JsonSerializer.Serialize(data);
var dataToCache = Encoding.UTF8.GetBytes(cachedDataString);
// Add the data into the cache
cacheKey = _redisConfig.Env + "_" + cacheKey;
await _cache.SetAsync(cacheKey, dataToCache, _options);
}
}
catch (Exception)
{
return;
}
}
Below is the code I used to retrieve cache using node js
npm package: redis: "^4.5.1",
exports.getRedisData = async (key) => {
try {
return await redisClient.get(key);
} catch (error) {
console.log(error);
return null
}
}
after executing the above solution the result I got is,
message: 'WRONGTYPE Operation against a key holding the wrong kind of value' Snap shot of the above error
Can anyone give me a clue to fix this ?