小编vul*_*ld0的帖子

为什么我使用 Redis 时会收到“ReplyError: ERRknown command JSON.SET”?

我试图将 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: …

redis node.js redisjson

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

node.js ×1

redis ×1

redisjson ×1