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

redisClient option not able to store apicache data in redis database #253

Open
ketansali opened this issue Mar 3, 2023 · 4 comments
Open

Comments

@ketansali
Copy link

No description provided.

@kincjf
Copy link

kincjf commented Mar 4, 2023

Me too, redis 6 7 all not able to store apicache data
so, redis.del(target) trigger error because for it's empty data
apicache\src\apicache.js:330:17

i use 3 client @upstash/redis, node-redis, ioredis
but doesn't write to redis

@lvendrame
Copy link

lvendrame commented Mar 8, 2023

If you want to use Redis, I created a little wrapper and solved it for me

const redis = require('redis');
const redisClient = redis.createClient();

redisClient.connect();

const redisWrapper = {
  connected: redisClient.isOpen,
  del: (keys) => { return redisClient.del(keys)},
  hgetall: (key, fn) => { redisClient.hGetAll(key)
    .then((resp) => {
      fn(null, resp);
    })
    .catch((err) => {
      fn(err);
    });},
  hset: (key, field, value) => { return redisClient.hSet(key, field, value)},
  expire: (key, seconds) => { return redisClient.expire(key, seconds)},
};

module.exports = redisWrapper;

@Sneidon
Copy link

Sneidon commented Aug 6, 2023

Thanks @lvendrame, the solution worked perfectly.

@AlexGamer29
Copy link

It's work for me. Thanks a lot!

If you want to use Redis, I created a little wrapper and solved it for me

const redis = require('redis');
const redisClient = redis.createClient();

redisClient.connect();

const redisWrapper = {
  connected: redisClient.isOpen,
  del: (keys) => { return redisClient.del(keys)},
  hgetall: (key, fn) => { redisClient.hGetAll(key)
    .then((resp) => {
      fn(null, resp);
    })
    .catch((err) => {
      fn(err);
    });},
  hset: (key, field, value) => { return redisClient.hSet(key, field, value)},
  expire: (key, seconds) => { return redisClient.expire(key, seconds)},
};

module.exports = redisWrapper;

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

No branches or pull requests

5 participants