多个进程可以访问我的redis商店。添加新
使用者
哈希,我执行以下步骤:
-
增量用户ID
-
设置用户:[递增的用户ID]。。。
如何将这些步骤捆绑到事务中?
const client = require('redis').createClient();
client.on("connect", () => {
const multi = client.multi();
multi.incr("userId", (userId) => {
console.log("new userId is %s", userId); // TODO userId should not be null
multi.set("user:"+userId, {name:"UserName"} );
});
multi.exec(); // TODO after the execution I expect to see the key user:null using redis-cli, but it does not exist
});