fakeredis icon indicating copy to clipboard operation
fakeredis copied to clipboard

Lua environmental differences

Open bmerry opened this issue 6 years ago • 4 comments

The Lua scripting support (EVAL) does not perfectly emulate the environment available to a real redis script. Some known differences are:

  • Libraries such as cjson are not loaded
  • Setting of global variables is only checked each time a redis function is called, rather than being enforced by a metatable.
  • dofile and readfile are not disabled.
  • Various functions on the redis object are not implemented e.g. redis.sha1hex, redis.log
  • It doesn't prevent mutating commands after a random command (this will be a major task since it requires knowing which commands are mutating and/or random).
  • The random seed might not be reset with every script (untested)

For more details see the redis documentation and implementation.

bmerry avatar Mar 23 '18 10:03 bmerry

Also found my scripts not working, as it requires cjson. I get attempt to index a nil value (global 'cjson') error

M1ha-Shvn avatar Oct 17 '19 06:10 M1ha-Shvn

Just wondering if any new release planning to address the first point?

  • Libraries such as cjson are not loaded

alifhughes avatar Feb 14 '20 08:02 alifhughes

Just wondering if any new release planning to address the first point?

I'm afraid I don't get enough time to spend on fakeredis to make it better (mostly I just try to keep it working as new versions of dependencies come out), and I'm not sure quite what would be involved since I don't use Lua myself. Pull requests are welcome.

bmerry avatar Feb 14 '20 08:02 bmerry

No worries, thanks for getting back to me quickly.

alifhughes avatar Feb 14 '20 09:02 alifhughes