Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support RedisJSON for storing JSON objects, change to Redis.call instead of Redis.get/set #122

Open
johnmanko opened this issue Jul 24, 2022 · 1 comment
Labels
feature New functionality or improvement

Comments

@johnmanko
Copy link

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): yes

Context

  • node version: 18.3.0
  • module version: 6.0.2
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): hapi.js
  • any other relevant information:

What problem are you trying to solve?

This project uses ioredis's Redis.psetex/get for writing and reading user data as string data. This requires applications to deserialize cache data when reading.

Do you have a new or modified API suggestion to solve the problem?

Alternatively, class Redis has a call method that supports direct Redis commands, such as GET, SET, JSON.GET, JSON.SET, etc. This project should be changed to exclusively use the call method and support all Redis supported commands. This can easily be done using a modifier to prefix commands.

Examples:

   redis.call('set', 'foo', 'bar');
   redis.call('json.set', 'foo', {bar: 'pickles'});
   redis.expire('foo', seconds);

With prefix = '', 'json.', etc based on plugin option

   redis.call(`${prefix}set`, 'foo', {bar: 'pickles'});
   redis.expire('foo', seconds);

There does seems to some inconsistency between the set/psetex methods and call. It would be nice to pass command options right on the call, but I guess the extra expire can take care of that if it can be done in an async way.

@johnmanko johnmanko added the feature New functionality or improvement label Jul 24, 2022
@kanongil
Copy link
Contributor

I don't see how the native JSON.<X> methods can give any advantage to us. They allow to directly access embedded JSON objects / values, but we always use the root. The interface to the REDIS server is still string-based, so there is no change in serialization, except that ioredis now controls it.

These new methods are also not compatible with the open-source releases of redis.

Finally, changing to use call will break the interface for users that use the client option with alternative or custom clients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

2 participants