如何使此操作成为原子?
redisClient.flushallAsync()
.then(() => redisClient.saddAsync('myset', ['a']))
.then(() => redisClient.saddAsync('myset_new', ['a', 'b', 'c']))
.then(() => redisClient.sdiffstoreAsync('myset_added', 'myset_new', 'myset'))
.then(() => redisClient.smembersAsync('myset_added'))
.then(result => Promise.all(_.map(result, newKey => redisClient.setAsync(newKey, ''))))
.then(result => redisClient.keysAsync('*'))
.then(result => console.log(result))
.catch(error => console.log(error));
输出:
[ 'myset_new', 'myset_added', 'myset', 'c', 'b' ]