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.

Make redis client be interchangable

See original GitHub issue

Hey just started using apicache, awesome so far. My problem is our production server is running on AWS with Elasticache (which as a default config is an redis-cluster) so my question is. Could it be possible to swap out the client to something like ioredis which supports cluster.

The code currently breaking at first glance is: return sendCachedResponse(res, JSON.parse(obj.response)) because the result from ioredis is slightly different.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kwhitleycommented, Jul 31, 2018

Can’t believe I left this ticket open for so long… this has long since been addressed by @Rauttis (added ioredis support)

Example

import Redis from 'ioredis';
import apicache from 'apicache';
const redis = new Redis(6379, '127.0.0.1');
const router = express.Router();

const cache = apicache.options({
  redisClient: redis
}).middleware;

const onlyStatus200 = (req, res) => res.statusCode === 200;

const cacheSuccesses = cache('5 minutes', onlyStatus200);

router.get('/cats', cacheSuccesses, async (req, res, next) => {
  cats.allCats(req, res, next);
});
1reaction
fabiel-leoncommented, Mar 16, 2018

& redis pool, how to do it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Redis client handling
The commands CLIENT SETNAME and CLIENT GETNAME can be used to set and get the connection name. Starting with Redis 4.0, the client...
Read more >
Is immutable.js interchangeable with redis on a server?
Redis is an in-memory database for your server that will be able to do very quick lookups and send that data to your...
Read more >
redis-mock - npm
The goal of the redis-mock project is to create a feature-complete mock of node_redis, which may be used interchangeably when writing unit tests ......
Read more >
faeldt/redis-mock: Node.js redis client mock - GitHub
The goal of the redis-mock project is to create a feature-complete mock of https://github.com/mranney/node_redis, so that it may be used interchangeably ...
Read more >
Redis with Node.js (node_redis) | Redis Documentation Center
The following example demonstrates how to make a connection to Redis using TLS: const redis = require('redis'); ...
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