question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Impossible to set Redis config

See original GitHub issue

First of all, I really like your lib. Keep up the good work !

I’m facing issues when trying to set the Redis cache options. I got this :

this.api = new KindredApi.Kindred({
  key: apiKey,
  defaultRegion: region,
  debug: !prod,
  showKey: true,
  showHeaders: false,
  limits: prod ? KindredApi.LIMITS.PROD : KindredApi.LIMITS.DEV,
  spread: false,
  retryOptions: {
    auto: true,
    numberOfRetriesBeforeBreak: 3,
  },
  timeout: 5000,
  cache: new KindredApi.RedisCache({ // Problem here, I can't set the options
    host: cache.redis.host || 'localhost',
    port: cache.redis.port || 6379,
    keyPrefix: cache.redis.prefix || 'league-tooltips_',
  }),
  cacheTTL: {
    STATIC: cache.TTL,
  },
});

The problem is that it is impossible to set the Redis config I want. They always get overridden by your default config. See here. Your code behaves this way : whatever the user gives, the default options are overriding it.

The way to fix this is to change the line to this :

var options = Object.assign({
  host: '127.0.0.1',
  port: 6379,
  keyPrefix: 'kindredAPI-'
}, opts || {});

The second problem is that the Wiki needs more docs about the RedisCache options. I had to dig in the lib code.

If you don’t have the time to fix this, I can send you a PR with the fixed code 😃

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Ilshidurcommented, Jul 29, 2017

Awesome ! Closing the issue, since you solved it 😃

0reactions
cnguycommented, Jul 29, 2017

@Ilshidur To run the tests, also set KEY_TO_RATE_LIMIT to your dev key (there’s a test that mocks the 429 retries until successful). I’ll add this to docs as well (Contributing?).

edit: I also have to update this test now that the rate limit has changed.

published to 2.0.74

Updated Wiki Docs to show current Redis options (https://github.com/ChauTNguyen/kindred-api/wiki/Caching#redis-cache-example) and also updated the README to have a small configurable Redis example in the README Introduction section.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redis configuration
The proper way to configure Redis is by providing a Redis configuration file, usually called redis.conf . The redis.conf file contains a number...
Read more >
How To Change Redis's Configuration from the Command ...
config set allows you to reconfigure Redis at runtime without having to restart the service. It uses the following syntax: config set parameter ......
Read more >
Unable to set configuration parameter "save" through the ...
I've started a Redis instance without a config file, with all parameters passed through command line. One of those parameters was the save ......
Read more >
How to Edit the Redis Configuration File - redis.conf
It is not necessary to edit the configuration file if you're simply going to test Redis, but if you're using it on a...
Read more >
Unable to start Redis server due to config file error
Make sure the rest of your stuff is setup, like init.d , conf and log files. Share.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found