Я реализую слой кэширования в NodeJS и MongoDB, используя Redis. Я довольно новичок в Redis. Поэтому у меня возникли проблемы, когда я пытаюсь автоматически очистить кеш после заданного времени. Я получаю ошибку
ReplyError: ERR wrong number of arguments for 'hset' command
Это мой кодовый блок
mongoose.Query.prototype.exec = async function() {
const key = JSON.stringify(
Object.assign({}, this.getQuery(), {collection:
this.mongooseCollection.name})
);
const cachedValue = await client.hget(this.hashKey, key);
if(cachedValue) {
const parsedDoc = JSON.parse(cachedValue);
return Array.isArray(parsedDoc) ? parsedDoc.map(doc => new
this.model(doc)) : new this.model(parsedDoc);
}
const result = await exec.apply(this, arguments);
client.hset(this.hashKey, key, JSON.stringify(result), 'EX', 10);
return result;
}