const Redis = require('ioredis');
const {getmac)= require(' getmac');
getmac();//获取mac地址
const cache = new Redis({
    port: 6300, // Redis port
    host: "192.100.50.256", // Redis host
    password: "123"
});
cache.get('eggsy').then(data => {
    console.log(15, data)
    if (data > 5) {
        throw new Error('big than 5');
    }
    if (!data) {
        cache.set('eggsy', 1, 'EX', 60);//设置60秒内访问次数大于5次,报错
    } else {
        cache.incr('eggsy');
    }

}).catch(err => {
    console.log(err)
})

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-03-02
  • 2021-07-26
  • 2022-01-05
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-28
  • 2022-01-31
  • 2022-12-23
  • 2021-08-16
  • 2021-12-02
  • 2022-12-23
相关资源
相似解决方案