我试图将 JSON 设置为 Redis 中的值,但收到以下代码的错误:
const createClient = require('redis');
async function redisJSONDemo () {
try {
const TEST_KEY = 'test_node';
const client = createClient.createClient();
await client.connect();
// RedisJSON uses JSON Path syntax. '.' is the root.
await client.json.set(TEST_KEY, '.', { node: 'blah' });
const value = await client.json.get(TEST_KEY, {
// JSON Path: .node = the element called 'node' at root level.
path: '.node'
});
console.log(`value of node: ${value}`);
await client.quit();
} catch (e) {
console.error(e);
}
}
redisJSONDemo();
Run Code Online (Sandbox Code Playgroud)
错误:
ReplyError: …