Impossible to set Redis config
See original GitHub issueFirst 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:
- Created 6 years ago
- Comments:6 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Awesome ! Closing the issue, since you solved it 😃
@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.