nrk / redis-lua

A Lua client library for the redis key value storage system.
MIT License
731 stars 239 forks source link

Large integers support #30

Open catwell opened 10 years ago

catwell commented 10 years ago

You use tostring to convert numbers to the Redis protocol format. This does not work correctly with integers above 10^14:

> =tostring(10^14-1)
99999999999999
> =tostring(10^14)
1e+14

It is possible to support numbers up to about 2^53, i.e. about 9*10^15, by using string.format instead:

> =string.format("%d",10^14)
100000000000000

Everything above 2^53-1 or below 2^53+1 is dangerous anyway, because you start seeing this:

> x = 2^53
> =(x == x+1)
true

Not sure how the client should handle this.

catwell commented 10 years ago

(related: https://github.com/catwell/fakeredis/commit/a076588b87f24b1f5982c01e3265074a81b95db0#diff-cb226e1732729d7a5e8f0508ee7de92eR127)