ioredis icon indicating copy to clipboard operation
ioredis copied to clipboard

Proposal: Make Script and Script.execute a stable api

Open TysonAndre opened this issue 4 years ago • 2 comments
trafficstars

For #1027

Having a stable low level api to evaluate scripts would be something I'd personally consider useful for:

  1. Third party libraries that prefer avoiding mutating the passed in redis instance
  2. Applications where the redis instance is a Proxy<Redis> (and the commands defined in other modules may be lost when the underlying instance changes).

If the concept makes sense to ioredis maintainers, more tests will be added.

Aside: Would adding Commander.getKeyPrefix make sense? Or should this stop passing in the keyPrefix to the Script constructor and use something like container?.options?.keyPrefix instead?

TysonAndre avatar Aug 04 '21 16:08 TysonAndre

Would adding Commander.getKeyPrefix make sense?

What would it look like with this approach? Should Script call that method?

luin avatar Aug 11 '21 14:08 luin

What would it look like with this approach? Should Script call that method?

Yes, that's what I had in mind so that a script could be called by any Commander and automatically use the right key prefix if they weren't overridden in an options object

I'd suggested that because I didn't know what guarantees the maintainers had about redisClient.options.keyPrefix being stable - would it work with ioredis-mock? Clusters or similar collections? Would it work in future refactorings (e.g. private properties decades from now).

TysonAndre avatar Aug 11 '21 14:08 TysonAndre