Giter Site home page Giter Site logo

redis-id-generator's Issues

生成的id重复问题

你好,我在demo中添加了所有生成的id放到安全的map key中。最后得到的id数量不正确,说明id重复了。

我的环境是单点redis。可能的原因是什么呢?

多线程异常

下载源码测试,开启500个线程测试会出现偶尔Could not return the resource to the pool异常

有没有可能因key被清除而导致重复发号

local count;
repeat
  count = tonumber(redis.call('INCRBY', miliSecondKey, step));
  if count > (1024 - step) then
      now = redis.call('TIME');
      miliSecondKey = prefix .. tag ..'_' .. partition .. '_' .. now[1] .. '_' .. math.floor(now[2]/1000);
  end
until count <= (1024 - step)

if count == step then
  redis.call('PEXPIRE', miliSecondKey, 5);
end

如上,如果某个毫秒下调用量很大,走进了count > (1024 - step),然后重新计算miliSecondKey,然后还是这个毫秒,然后在下次循环count = tonumber(redis.call('INCRBY', miliSecondKey, step));之前,这个毫秒key被redis后台检查超时超过了5毫秒而删除了,那么这时候count将又回到step,毫秒也是之前的毫秒,这时候不就重复了吗?

关于jedis调用Lua脚本的问题

在lua脚本中有一个key做incrby,通过jedis调用,通过keys *命令,这个key并没有设置到redis中,我通过./bin/redis-cli --eval redis-script-node1.lua是有设置这个key的

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.